diff --git a/.circleci/config.yml b/.circleci/config.yml index 3e3a8d52b..819cff015 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,39 +1,56 @@ -version: 2 +version: 2.1 +orbs: + ship: auth0/ship@0.3.1 + codecov: codecov/codecov@3 jobs: build-and-test: + parameters: + node-version: + type: string + default: "14.20" docker: - - image: circleci/node:6.14.3-browsers + - image: cimg/node:<< parameters.node-version >> environment: - LANG: en_US.UTF-8 + LANG: en_US.UTF-8 steps: - checkout - - run: - name: Update Yarn - command: 'sudo npm update -g yarn' - - restore-cache: + - restore_cache: name: Restore Yarn Package Cache - keys: - - yarn-packages-{{ checksum "yarn.lock" }} + key: yarn-packages-{{ checksum "yarn.lock" }} - run: name: Install Dependencies - command: yarn install --frozen-lockfile - - save-cache: + command: yarn install --ignore-engines + - save_cache: name: Save Yarn Package Cache key: yarn-packages-{{ checksum "yarn.lock" }} paths: - ~/.cache/yarn - - run: - name: Check - command: yarn check - - run: + - run: + name: ESLint + command: yarn lint + - run: name: Tests command: yarn test:ci - - run: - name: Generate Coverage - command: yarn test:coverage - + - when: + condition: + equal: [ "14.20", << parameters.node-version >> ] + steps: + - codecov/upload workflows: - version: 2 build-test-report: jobs: - - build-and-test + - build-and-test: + matrix: + parameters: + node-version: ["14.20", "16.18", "18.12"] + - ship/node-publish: + pkg-manager: yarn + requires: + - build-and-test + context: + - publish-npm + - publish-gh + filters: + branches: + only: + - master diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..7969ef326 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +!.mocharc.js +docs +out diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..31e3bfa06 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,55 @@ +module.exports = { + env: { + node: true, + commonjs: true, + es2017: true, + mocha: true, + }, + extends: [ + 'eslint:recommended', + 'plugin:jsdoc/recommended', + 'plugin:node/recommended', + 'plugin:promise/recommended', + 'plugin:prettier/recommended', + ], + plugins: ['jsdoc'], + parserOptions: { + ecmaVersion: 9, + }, + rules: { + 'arrow-body-style': 'error', + 'arrow-parens': 'error', + 'arrow-spacing': 'error', + 'generator-star-spacing': 'error', + 'no-confusing-arrow': 'error', + 'no-duplicate-imports': 'error', + 'no-restricted-exports': 'error', + 'no-restricted-imports': 'error', + 'no-useless-computed-key': 'error', + 'no-useless-constructor': 'error', + 'no-useless-rename': 'error', + 'no-var': 'error', + 'object-shorthand': 'error', + 'prefer-arrow-callback': 'error', + 'prefer-const': 'error', + 'prefer-destructuring': 'error', + 'prefer-numeric-literals': 'error', + 'prefer-rest-params': 'error', + 'prefer-spread': 'error', + 'prefer-template': 'error', + 'rest-spread-spacing': 'error', + 'sort-imports': 'error', + 'symbol-description': 'error', + 'template-curly-spacing': 'error', + 'yield-star-spacing': 'error', + + 'jsdoc/require-jsdoc': ['warn', { publicOnly: true }], + 'jsdoc/require-returns-description': 'off', + 'jsdoc/no-undefined-types': 'off', + 'jsdoc/require-param': 'off', + 'jsdoc/check-param-names': 'off', + + 'promise/catch-or-return': 'off', + 'promise/always-return': 'off', + }, +}; diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..60f116c05 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @auth0/dx-sdks-engineer diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..40476968a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Auth0 Community + url: https://community.auth0.com/c/sdks/5 + about: Discuss this SDK in the Auth0 Community forums + - name: Library Documentation + url: https://auth0.github.io/node-auth0/ + about: Read the library docs diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..62a5822b5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,39 @@ +--- +name: Feature request +about: Suggest an idea or a feature for this project +title: '' +labels: feature request +assignees: '' +--- + + + +### Describe the problem you'd like to have solved + + + +### Describe the ideal solution + + + +## Alternatives and current work-arounds + + + +### Additional information, if any + + diff --git a/.github/ISSUE_TEMPLATE/report_a_bug.md b/.github/ISSUE_TEMPLATE/report_a_bug.md new file mode 100644 index 000000000..e0dac8a1d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/report_a_bug.md @@ -0,0 +1,56 @@ +--- +name: Report a bug +about: Have you found a bug or issue? Create a bug report for this SDK +title: '' +labels: bug report +assignees: '' +--- + + + +### Describe the problem + + + +### What was the expected behavior? + + + +### Reproduction + + + +- Step 1.. +- Step 2.. +- ... + +### Environment + + + +- **Version of this library used:** +- **Which framework are you using, if applicable:** +- **Other modules/plugins/libraries that might be involved:** +- **Any other relevant information you think would be useful:** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..826afddf0 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,31 @@ +### Changes + +Please describe both what is changing and why this is important. Include: + +- Endpoints added, deleted, deprecated, or changed +- Classes and methods added, deleted, deprecated, or changed +- Screenshots of new or changed UI, if applicable +- A summary of usage if this is a new feature or change to a public API (this should also be added to relevant documentation once released) +- Any alternative designs or approaches considered + +### References + +Please include relevant links supporting this change such as a: + +- support ticket +- community post +- StackOverflow post +- support forum thread + +### Testing + +Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors. + +- [ ] This change adds unit test coverage +- [ ] This change adds integration test coverage + +### Checklist + +- [ ] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md) +- [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) +- [ ] All existing and new tests complete without errors diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 000000000..b2e13fc71 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,20 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 90 + +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. +daysUntilClose: 7 + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: [] + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: true + +# Label to use when marking as stale +staleLabel: closed:stale + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️ \ No newline at end of file diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml new file mode 100644 index 000000000..916745ee4 --- /dev/null +++ b/.github/workflows/semgrep.yml @@ -0,0 +1,25 @@ +name: Semgrep + +on: + pull_request: {} + + push: + branches: ["master", "main"] + + schedule: + - cron: '30 0 1,15 * *' + +jobs: + semgrep: + name: Scan + runs-on: ubuntu-latest + container: + image: returntocorp/semgrep + # Skip any PR created by dependabot to avoid permission issues + if: (github.actor != 'dependabot[bot]') + steps: + - uses: actions/checkout@v3 + + - run: semgrep ci + env: + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} diff --git a/.gitignore b/.gitignore index 11444ff23..14359e600 100644 --- a/.gitignore +++ b/.gitignore @@ -33,14 +33,15 @@ node_modules # Compressed files. *.tgz -# InelliJ IDEA +# IntelliJ IDEA .idea build **/.env out/ test-results.xml +.nyc_output -# Release process -.release -.release-tmp-*/ \ No newline at end of file + +# npm +package-lock.json \ No newline at end of file diff --git a/.jsdoc.json b/.jsdoc.json index 05d137a62..1e02225d1 100644 --- a/.jsdoc.json +++ b/.jsdoc.json @@ -1,32 +1,24 @@ { - "tags": { - "allowUnknownTags": true, - "dictionaries": [ - "jsdoc" - ] - }, - "source": { - "include": [ - "src", - "package.json", - "README.md" - ], - "includePattern": ".js$", - "excludePattern": "(node_modules/|docs|test)" - }, - "plugins": [ - "./node_modules/jsdoc/plugins/markdown" - ], - "templates": { - "cleverLinks": false, - "monospaceLinks": true, - "useLongnameInNav": false - }, - "opts": { - "destination": "./out/", - "encoding": "utf8", - "private": false, - "recurse": true, - "template": "./node_modules/minami" - } -} \ No newline at end of file + "tags": { + "allowUnknownTags": true, + "dictionaries": ["jsdoc"] + }, + "source": { + "include": ["src", "package.json", "README.md"], + "includePattern": ".js$", + "excludePattern": "(node_modules/|docs|test)" + }, + "plugins": ["./node_modules/jsdoc/plugins/markdown"], + "templates": { + "cleverLinks": false, + "monospaceLinks": true, + "useLongnameInNav": false + }, + "opts": { + "destination": "./out/", + "encoding": "utf8", + "private": false, + "recurse": true, + "template": "./node_modules/minami" + } +} diff --git a/.nycrc b/.nycrc new file mode 100644 index 000000000..7bc74855c --- /dev/null +++ b/.nycrc @@ -0,0 +1,7 @@ +{ + "reporter" : ["text-summary", "lcov"], + "include" : ["src/**/*.js"], + "sourceMap" : false, + "instrument" : true, + "all" : true +} \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..9b964aaf2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +docs/* +.circleci/* diff --git a/.shiprc b/.shiprc new file mode 100644 index 000000000..6fea8524b --- /dev/null +++ b/.shiprc @@ -0,0 +1,3 @@ +{ + "postbump": "node scripts/jsdocs.js" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 06f7972ba..df760e176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,515 @@ # Change Log +## [v3.0.1](https://github.com/auth0/node-auth0/tree/v3.0.1) (2022-12-22) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v3.0.0...v3.0.1) + +**Fixed** + +- bump jwks-rsa [\#769](https://github.com/auth0/node-auth0/pull/769) ([adamjmcgrath](https://github.com/adamjmcgrath)) + +## [v3.0.0](https://github.com/auth0/node-auth0/tree/v3.0.0) (2022-12-22) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.44.1...v3.0.0) + +**⚠️ BREAKING CHANGES** + +- Update jsonwebtoken [\#766](https://github.com/auth0/node-auth0/pull/766) ([adamjmcgrath](https://github.com/adamjmcgrath)) + +This release drops support for Node versions <14. + +## [v2.44.1](https://github.com/auth0/node-auth0/tree/v2.44.1) (2022-12-09) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.44.0...v2.44.1) + +**Fixed** + +- Prevent calling the callback more than once [\#759](https://github.com/auth0/node-auth0/pull/759) ([snocorp](https://github.com/snocorp)) + +## [v2.44.0](https://github.com/auth0/node-auth0/tree/v2.44.0) (2022-10-11) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.43.0...v2.44.0) + +**Added** + +- [SDK-3653] Add proxy support to Management Client [\#747](https://github.com/auth0/node-auth0/pull/747) ([adamjmcgrath](https://github.com/adamjmcgrath)) + +## [v2.43.0](https://github.com/auth0/node-auth0/tree/v2.43.0) (2022-10-10) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.42.0...v2.43.0) + +**Added** + +- Add option to include response headers in the result [\#744](https://github.com/auth0/node-auth0/pull/744) ([adamjmcgrath](https://github.com/adamjmcgrath)) + +## [v2.42.0](https://github.com/auth0/node-auth0/tree/v2.42.0) (2022-05-23) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.41.0...v2.42.0) + +**Added** + +- chore: add branding theme routes [\#725](https://github.com/auth0/node-auth0/pull/725) ([alejofernandez](https://github.com/alejofernandez)) + +## [v2.41.0](https://github.com/auth0/node-auth0/tree/v2.41.0) (2022-05-20) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.40.0...v2.41.0) + +**Added** + +- Added ClientsManager.rotateClientSecret method [\#721](https://github.com/auth0/node-auth0/pull/721) ([sbmelvin](https://github.com/sbmelvin)) + +## [v2.40.0](https://github.com/auth0/node-auth0/tree/v2.40.0) (2022-02-11) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.39.0...v2.40.0) + +**Added** + +- [CAUTH-1270]: feat(attack protection): add three features (bf, sipt, bpd) [\#705](https://github.com/auth0/node-auth0/pull/705) ([sdwvit](https://github.com/sdwvit)) + +## [v2.39.0](https://github.com/auth0/node-auth0/tree/v2.39.0) (2022-01-31) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.38.1...v2.39.0) + +**Added** + +- feat: update draft deploy [\#702](https://github.com/auth0/node-auth0/pull/702) ([TwelveNights](https://github.com/TwelveNights)) + +## [v2.38.1](https://github.com/auth0/node-auth0/tree/v2.38.1) (2022-01-27) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.38.0...v2.38.1) + +**Fixed** + +- Fix wrong property in `assignRolestoUser` [\#700](https://github.com/auth0/node-auth0/pull/700) ([adamjmcgrath](https://github.com/adamjmcgrath)) +- signIn method should provide using audience prop in userData [\#699](https://github.com/auth0/node-auth0/pull/699) ([maxism](https://github.com/maxism)) + +## [v2.38.0](https://github.com/auth0/node-auth0/tree/v2.38.0) (2022-01-26) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.37.0...v2.38.0) + +**Changed** + +- refactor to es6 syntax with classes [\#665](https://github.com/auth0/node-auth0/pull/665) ([hornta](https://github.com/hornta)) + +**Fixed** + +- [SDK-3030] Wrong url when doing assign users with a callback [\#686](https://github.com/auth0/node-auth0/pull/686) ([adamjmcgrath](https://github.com/adamjmcgrath)) + +## [v2.37.0](https://github.com/auth0/node-auth0/tree/v2.37.0) (2021-10-14) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.36.2...v2.37.0) + +**Added** + +- Add support for checking connection status [\#662](https://github.com/auth0/node-auth0/pull/662) ([frederikprijck](https://github.com/frederikprijck)) + +**Fixed** + +- Fix undefined tokenProvider when access token is provided. [\#642](https://github.com/auth0/node-auth0/pull/642) ([Gilighost](https://github.com/Gilighost)) + +## [v2.36.2](https://github.com/auth0/node-auth0/tree/v2.36.2) (2021-09-20) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.36.1...v2.36.2) + +**Security** + +- [Snyk] Security upgrade rest-facade from 1.13.0 to 1.13.1 [\#653](https://github.com/auth0/node-auth0/pull/653) ([snyk-bot](https://github.com/snyk-bot)) +- [Snyk] Security upgrade axios from 0.21.1 to 0.21.3 [\#649](https://github.com/auth0/node-auth0/pull/649) ([snyk-bot](https://github.com/snyk-bot)) + +## [v2.36.1](https://github.com/auth0/node-auth0/tree/v2.36.1) (2021-07-28) + +**Fixed** + +- Fix docs for rate limit default maxRetries [\#640](https://github.com/auth0/node-auth0/pull/640) ([jimmyjames](https://github.com/jimmyjames)) +- Fix updateCustomTextByLanguage [\#638](https://github.com/auth0/node-auth0/pull/638) ([davidpatrick](https://github.com/davidpatrick)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.36.0...v2.36.1) + +## [v2.36.0](https://github.com/auth0/node-auth0/tree/v2.36.0) (2021-07-23) + +**Added** + +- [SDK-2666] Update endpoint methods to document allowance of 'from' and 'take' checkpoint pagination parameters [\#634](https://github.com/auth0/node-auth0/pull/634) ([evansims](https://github.com/evansims)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.35.1...v2.36.0) + +## [v2.35.1](https://github.com/auth0/node-auth0/tree/v2.35.1) (2021-06-21) + +**Fixed** + +- Update `setUniversalLoginTemplate` example to correctly reflect documentation [\#624](https://github.com/auth0/node-auth0/pull/624) ([mendhak](https://github.com/mendhak)) +- Use id instead of action_id as per the mgmt api. [\#622](https://github.com/auth0/node-auth0/pull/622) ([stevezau](https://github.com/stevezau)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.35.0...v2.35.1) + +## [v2.35.0](https://github.com/auth0/node-auth0/tree/v2.35.0) (2021-05-17) + +**Added** + +- Add method to verify OTP received via email [\#620](https://github.com/auth0/node-auth0/pull/620) ([alexesprit](https://github.com/alexesprit)) +- [actionsManager] Adding new Actions Managment APIs [\#570](https://github.com/auth0/node-auth0/pull/570) ([shushen](https://github.com/shushen)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.34.2...v2.35.0) + +## [v2.34.2](https://github.com/auth0/node-auth0/tree/v2.34.2) (2021-04-12) + +**Fixed** + +- [SDK-2484] Encode user ids on patch/update/delete [\#608](https://github.com/auth0/node-auth0/pull/608) ([davidpatrick](https://github.com/davidpatrick)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.34.1...v2.34.2) + +## [v2.34.1](https://github.com/auth0/node-auth0/tree/v2.34.1) (2021-04-01) + +**Fixed** + +- Small fix to ManagementTokenProvider Cache [\#604](https://github.com/auth0/node-auth0/pull/604) ([davidpatrick](https://github.com/davidpatrick)) + +**Security** + +- Bump y18n from 4.0.0 to 4.0.1 [\#602](https://github.com/auth0/node-auth0/pull/602) ([dependabot-preview](https://github.com/dependabot-preview)) +- Security upgrade jwks-rsa from 1.10.0 to 1.12.1 [\#601](https://github.com/auth0/node-auth0/pull/601) ([snyk-bot](https://github.com/snyk-bot)) + +## [v2.34.0](https://github.com/auth0/node-auth0/tree/v2.34.0) (2021-03-24) + +**Added** + +- feat(orgs): Support Organization feature [\#592](https://github.com/auth0/node-auth0/pull/592) ([mcastany](https://github.com/mcastany)) +- Org idtoken validation support [\#597](https://github.com/auth0/node-auth0/pull/597) ([davidpatrick](https://github.com/davidpatrick)) +- Allow passwordless SMS code verification to use token endpoint [\#591](https://github.com/auth0/node-auth0/pull/591) ([jimmyjames](https://github.com/jimmyjames)) + +**Changed** + +- Doc Updates [\#599](https://github.com/auth0/node-auth0/pull/599) ([davidpatrick](https://github.com/davidpatrick)) +- Update get role users docs [\#587](https://github.com/auth0/node-auth0/pull/587) ([jhiner](https://github.com/jhiner)) +- revokeRefreshToken method is missing in docs [\#584](https://github.com/auth0/node-auth0/issues/584) + +**Security** + +- [Security] Bump elliptic from 6.5.3 to 6.5.4 [\#589](https://github.com/auth0/node-auth0/pull/589) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.33.0...v2.34.0) + +## [v2.33.0](https://github.com/auth0/node-auth0/tree/v2.33.0) (2021-02-05) + +**Added** + +- feat: add revokeRefreshToken [\#579](https://github.com/auth0/node-auth0/pull/579) ([andreafspeziale](https://github.com/andreafspeziale)) +- ULP-2609/ULP-2914: add page templates support to /branding [\#574](https://github.com/auth0/node-auth0/pull/574) ([sebadoom](https://github.com/sebadoom)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.32.0...v2.33.0) + +## [v2.32.0](https://github.com/auth0/node-auth0/tree/v2.32.0) (2021-01-21) + +**Added** + +- Additional options on getByEmail [SDK-2268][\#577](https://github.com/auth0/node-auth0/pull/577) ([davidpatrick](https://github.com/davidpatrick)) +- [SDK-2261] Add forwardFor support to passwordless calls [\#576](https://github.com/auth0/node-auth0/pull/576) ([frederikprijck](https://github.com/frederikprijck)) +- Adding Support for Guardian factor settings endpoints [\#569](https://github.com/auth0/node-auth0/pull/569) ([JayHelton](https://github.com/JayHelton)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.31.1...v2.32.0) + +## [v2.31.1](https://github.com/auth0/node-auth0/tree/v2.31.1) (2021-01-05) + +**Fixed** + +- Expose getJobErrors to management client [\#563](https://github.com/auth0/node-auth0/pull/563) ([davidaubin19](https://github.com/davidaubin19)) +- Fix passing a custom User-Agent to Axios. [\#562](https://github.com/auth0/node-auth0/pull/562) ([djanowski](https://github.com/djanowski)) +- Expose assignUsersToRole to ManagementClient [\#561](https://github.com/auth0/node-auth0/pull/561) ([davidaubin19](https://github.com/davidaubin19)) + +**Security** + +- [Security] Bump axios from 0.19.2 to 0.21.1 [\#565](https://github.com/auth0/node-auth0/pull/565) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.31.0...v2.31.1) + +## [v2.31.0](https://github.com/auth0/node-auth0/tree/v2.31.0) (2020-12-08) + +**Added** + +- Updated documentation on Link Users [\#558](https://github.com/auth0/node-auth0/pull/558) ([davidpatrick](https://github.com/davidpatrick)) +- Add support for new passwordless endpoint [\#556](https://github.com/auth0/node-auth0/pull/556) ([nbandarchi](https://github.com/nbandarchi)) + +**Fixed** + +- Adds importUsersJob to ManagementClient [\#553](https://github.com/auth0/node-auth0/pull/553) ([mikemeerschaert](https://github.com/mikemeerschaert)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.30.0...v2.31.0) + +## [v2.30.0](https://github.com/auth0/node-auth0/tree/v2.30.0) (2020-10-22) + +**Added** + +- Provide headers on mgmt token fetch [\#543](https://github.com/auth0/node-auth0/pull/543) ([davidpatrick](https://github.com/davidpatrick)) + +**Changed** + +- [SDK-1975] Use exponential backoff rather than rate limit headers [\#538](https://github.com/auth0/node-auth0/pull/538) ([adamjmcgrath](https://github.com/adamjmcgrath)) + +**Fixed** + +- Bumps Rest-Facade Dependencies [\#542](https://github.com/auth0/node-auth0/pull/542) ([davidpatrick](https://github.com/davidpatrick)) +- Fix deprecation warning in importUserJobs [\#537](https://github.com/auth0/node-auth0/pull/537) ([JCQuintas](https://github.com/JCQuintas)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.29.0...v2.30.0) + +## [v2.29.0](https://github.com/auth0/node-auth0/tree/v2.29.0) (2020-09-23) + +**Added** + +- Adding support for prompts and custom texts [\#533](https://github.com/auth0/node-auth0/pull/533) ([davidpatrick](https://github.com/davidpatrick)) +- Adding call to invalidate all remembered browsers. [\#528](https://github.com/auth0/node-auth0/pull/528) ([tandrup](https://github.com/tandrup)) +- Adding docs for secondary and federated identity email verification [\#519](https://github.com/auth0/node-auth0/pull/519) ([jimmyjames](https://github.com/jimmyjames)) + +**Changed** + +- Update dependencies [\#535](https://github.com/auth0/node-auth0/pull/535) ([davidpatrick](https://github.com/davidpatrick)) +- Update jwks-rsa dependency to avoid DeprecationWarning Buffer() [\#534](https://github.com/auth0/node-auth0/pull/534) ([jalie](https://github.com/jalie)) + +**Security** + +- [Security] Bump node-fetch from 2.6.0 to 2.6.1 [\#532](https://github.com/auth0/node-auth0/pull/532) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.28.0...v2.29.0) + +## [v2.28.0](https://github.com/auth0/node-auth0/tree/v2.28.0) (2020-08-27) + +**Added** + +- Added support for Log Streams [\#518](https://github.com/auth0/node-auth0/pull/518) ([cv711](https://github.com/cv711)) + +**Removed** + +- Remove bluebird [\#520](https://github.com/auth0/node-auth0/pull/520) ([mattiasnixell](https://github.com/mattiasnixell)) + +**Security** + +- [Security] Bump elliptic from 6.5.2 to 6.5.3 [\#521](https://github.com/auth0/node-auth0/pull/521) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.27.1...v2.28.0) + +## [v2.27.1](https://github.com/auth0/node-auth0/tree/v2.27.1) (2020-07-23) + +**Changed** + +- Use [REDACTED] instead of [SANITIZED] when cleaning errors [\#515](https://github.com/auth0/node-auth0/pull/515) ([jimmyjames](https://github.com/jimmyjames)) + +**Security** + +- Sanitize Headers on Errors [\#507](https://github.com/auth0/node-auth0/pull/507) ([jimmyjames](https://github.com/jimmyjames)) +- Bump lodash from 4.17.15 to 4.17.19 [\#506](https://github.com/auth0/node-auth0/pull/506) ([dependabot[bot]](https://github.com/apps/dependabot)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.27.0...v2.27.1) + +## [v2.27.0](https://github.com/auth0/node-auth0/tree/v2.27.0) (2020-06-30) + +**Added** + +- feat(migrations): adds migrations manager [\#503](https://github.com/auth0/node-auth0/pull/503) ([CriGoT](https://github.com/CriGoT)) +- Added deleteUserByEmail to ConnectionsManager [\#502](https://github.com/auth0/node-auth0/pull/502) ([MatthewBacalakis](https://github.com/MatthewBacalakis)) +- feat(guardian): support policies, selected-provider, message-types methods [MFA-310][\#501](https://github.com/auth0/node-auth0/pull/501) ([pmalouin](https://github.com/pmalouin)) + +**Fixed** + +- fix: management methods throwing error on access [\#500](https://github.com/auth0/node-auth0/pull/500) ([pmalouin](https://github.com/pmalouin)) +- fix: guardian-related code examples [\#499](https://github.com/auth0/node-auth0/pull/499) ([pmalouin](https://github.com/pmalouin)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.26.0...v2.27.0) + +## [v2.26.0](https://github.com/auth0/node-auth0/tree/v2.26.0) (2020-06-05) + +**Added** + +- JobsManager handling importUsers response payload [\#492](https://github.com/auth0/node-auth0/pull/492) ([davidpatrick](https://github.com/davidpatrick)) + +**Deprecated** + +- Deprecate importUsers in favor of importUsersJob [\#494](https://github.com/auth0/node-auth0/pull/494) ([davidpatrick](https://github.com/davidpatrick)) + +**Fixed** + +- Bump codecov - npm audit fix [\#495](https://github.com/auth0/node-auth0/pull/495) ([davidpatrick](https://github.com/davidpatrick)) + +**Security** + +- Fixes dependency vulnerabilities from webpack [\#498](https://github.com/auth0/node-auth0/pull/498) ([davidpatrick](https://github.com/davidpatrick)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.25.1...v2.26.0) + +## [v2.25.1](https://github.com/auth0/node-auth0/tree/v2.25.1) (2020-05-03) + +**Fixed** + +- Return response.data where Axios is used [\#484](https://github.com/auth0/node-auth0/pull/484) ([taylorbryant](https://github.com/taylorbryant)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.25.0...v2.25.1) + +## [v2.25.0](https://github.com/auth0/node-auth0/tree/v2.25.0) (2020-04-29) + +**Changed** + +- Deprecate Request lib [\#475](https://github.com/auth0/node-auth0/pull/475) ([davidpatrick](https://github.com/davidpatrick)) + +**Fixed** + +- Fix typos [\#480](https://github.com/auth0/node-auth0/pull/480) ([pgrimaud](https://github.com/pgrimaud)) +- Update getRulesConfigs docs to include callback [\#473](https://github.com/auth0/node-auth0/pull/473) ([akvamalin](https://github.com/akvamalin)) + +**Security** + +- Dependency bump [\#481](https://github.com/auth0/node-auth0/pull/481) ([davidpatrick](https://github.com/davidpatrick)) +- [Security] Bump acorn from 6.2.1 to 6.4.1 [\#471](https://github.com/auth0/node-auth0/pull/471) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.24.0...v2.25.0) + +## [v2.24.0](https://github.com/auth0/node-auth0/tree/v2.24.0) (2020-03-06) + +**Fixed** + +- Update and fix JSDocs related to JobsManager [\#469](https://github.com/auth0/node-auth0/pull/469) ([orangain](https://github.com/orangain)) +- Fixes test on supportedAlgorithms [\#466](https://github.com/auth0/node-auth0/pull/466) ([davidpatrick](https://github.com/davidpatrick)) +- Fixes calls on passwordless endpoints [\#465](https://github.com/auth0/node-auth0/pull/465) ([davidpatrick](https://github.com/davidpatrick)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.23.0...v2.24.0) + +## [v2.23.0](https://github.com/auth0/node-auth0/tree/v2.23.0) (2020-02-21) + +**Added** + +- [DXEX-455] Allow custom headers to be set in Management/Auth Clients. [\#460](https://github.com/auth0/node-auth0/pull/460) ([seejee](https://github.com/seejee)) + +**Changed** + +- Updates node-jwks-rsa [\#461](https://github.com/auth0/node-auth0/pull/461) ([davidpatrick](https://github.com/davidpatrick)) + +**Fixed** + +- Update lru-memoizer dependency to avoid DeprecationWarning Buffer() [\#459](https://github.com/auth0/node-auth0/pull/459) ([jalie](https://github.com/jalie)) +- getUsersInRole Docs [\#457](https://github.com/auth0/node-auth0/pull/457) ([davidpatrick](https://github.com/davidpatrick)) + +**Security** + +- [Security] Bump codecov from 3.5.0 to 3.6.5 [\#462](https://github.com/auth0/node-auth0/pull/462) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.22.0...v2.23.0) + +## [v2.22.0](https://github.com/auth0/node-auth0/tree/v2.22.0) (2020-01-24) + +**Added** + +- Support for Hooks API [\#440](https://github.com/auth0/node-auth0/pull/440) ([astanciu](https://github.com/astanciu)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.21.0...v2.22.0) + +## [v2.21.0](https://github.com/auth0/node-auth0/tree/v2.21.0) (2020-01-15) + +**Added** + +- Improved OIDC compliance [\#446](https://github.com/auth0/node-auth0/pull/446) ([davidpatrick](https://github.com/davidpatrick)) + +**Changed** + +- Add client secret to refreshToken and remove ID token validation [\#433](https://github.com/auth0/node-auth0/pull/433) ([joshcanhelp](https://github.com/joshcanhelp)) + +**Security** + +- [Security] Bump handlebars from 4.1.2 to 4.5.3 [\#441](https://github.com/auth0/node-auth0/pull/441) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Update rest-facade dependency [\#436](https://github.com/auth0/node-auth0/pull/436) ([joshcanhelp](https://github.com/joshcanhelp)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.20.0...v2.21.0) + +## [v2.20.0](https://github.com/auth0/node-auth0/tree/v2.20.0) (2019-09-17) + +**Added** + +- expose createEmailTemplate, getEmailTemplate, updateEmailTemplates vi… [\#416](https://github.com/auth0/node-auth0/pull/416) ([rameshanandakrishnan](https://github.com/rameshanandakrishnan)) + +**Security** + +- Sanitize Error Request Data [\#424](https://github.com/auth0/node-auth0/pull/424) ([davidpatrick](https://github.com/davidpatrick)) +- [Security] Bump mixin-deep from 1.3.1 to 1.3.2 [\#421](https://github.com/auth0/node-auth0/pull/421) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.19.0...v2.20.0) + +## [v2.18.1](https://github.com/auth0/node-auth0/tree/v2.19.0) (2019-08-08) + +**Added** + +- Implement auth0-forwarded-for header passing in Authentication Client [\#401](https://github.com/auth0/node-auth0/pull/401) ([kjarmicki](https://github.com/kjarmicki)) + +**Changed** + +- Improve JobManager (get errors + parse error message when importing users) [\#407](https://github.com/auth0/node-auth0/pull/407) ([jbauth0](https://github.com/jbauth0)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.18.1...v2.19.0) + +## [v2.18.0](https://github.com/auth0/node-auth0/tree/v2.18.1) (2019-07-23) + +**Changed** + +- Encode id param on GET [\#374](https://github.com/auth0/node-auth0/pull/374) ([luisrudge](https://github.com/luisrudge)) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.18.0...v2.18.1) + +## [v2.18.0](https://github.com/auth0/node-auth0/tree/v2.18.0) (2019-06-26) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.17.1...v2.18.0) + +**Added** + +- Add Management API support for Branding and Prompts endpoints. [\#370](https://github.com/auth0/node-auth0/pull/370) ([chrisscott](https://github.com/chrisscott)) + +## [v2.17.1](https://github.com/auth0/node-auth0/tree/v2.17.1) (2019-05-22) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.17.0...v2.17.1) + +**Fixed** + +- Fix telemetry header [\#362](https://github.com/auth0/node-auth0/pull/362) ([lbalmaceda](https://github.com/lbalmaceda)) + +## [v2.17.0](https://github.com/auth0/node-auth0/tree/v2.17.0) (2019-04-15) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.16.0...v2.17.0) + +**Added** + +- Add method to assign users to a role [\#348](https://github.com/auth0/node-auth0/pull/348) ([pushpabrol](https://github.com/pushpabrol)) +- Add support for roles and permissions [\#344](https://github.com/auth0/node-auth0/pull/344) ([pushpabrol](https://github.com/pushpabrol)) + +## [v2.16.0](https://github.com/auth0/node-auth0/tree/v2.16.0) (2019-03-18) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.15.0...v2.16.0) + +**Added** + +- Add support for Auth0 Grants [\#343](https://github.com/auth0/node-auth0/pull/343) ([jsmpereira](https://github.com/jsmpereira)) + +## [v2.15.0](https://github.com/auth0/node-auth0/tree/v2.15.0) (2019-03-11) + +[Full Changelog](https://github.com/auth0/node-auth0/compare/v2.14.0...v2.15.0) + +**Added** + +- Add users-exports endpoint [\#340](https://github.com/auth0/node-auth0/pull/340) ([arjenvanderende](https://github.com/arjenvanderende)) + +**Fixed** + +- Don't validate id_token when alg is HS256 and there is no clientSecret [\#330](https://github.com/auth0/node-auth0/pull/330) ([luisrudge](https://github.com/luisrudge)) + ## [v2.14.0](https://github.com/auth0/node-auth0/tree/v2.14.0) (2018-11-12) [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.13.0...v2.14.0) **Added** -* Add method to refresh a token using a refresh_token [\#313](https://github.com/auth0/node-auth0/pull/313) ([modeswitch](https://github.com/modeswitch)) -* Add all Guardian APIs [\#311](https://github.com/auth0/node-auth0/pull/311) ([stevezau](https://github.com/stevezau)) -* Add Custom Domains methods [\#310](https://github.com/auth0/node-auth0/pull/310) ([stevezau](https://github.com/stevezau)) -* Add send_completion_email and upsert params for importUsers [\#270](https://github.com/auth0/node-auth0/pull/270) ([Floppy](https://github.com/Floppy)) +- Add method to refresh a token using a refresh_token [\#313](https://github.com/auth0/node-auth0/pull/313) ([modeswitch](https://github.com/modeswitch)) +- Add all Guardian APIs [\#311](https://github.com/auth0/node-auth0/pull/311) ([stevezau](https://github.com/stevezau)) +- Add Custom Domains methods [\#310](https://github.com/auth0/node-auth0/pull/310) ([stevezau](https://github.com/stevezau)) +- Add send_completion_email and upsert params for importUsers [\#270](https://github.com/auth0/node-auth0/pull/270) ([Floppy](https://github.com/Floppy)) **Deprecated** -* Deprecate UsersManager.deleteAll and deleteAllUsers wrapper methods [\#309](https://github.com/auth0/node-auth0/pull/309) ([M-Zuber](https://github.com/M-Zuber)) +- Deprecate UsersManager.deleteAll and deleteAllUsers wrapper methods [\#309](https://github.com/auth0/node-auth0/pull/309) ([M-Zuber](https://github.com/M-Zuber)) ## [v2.13.0](https://github.com/auth0/node-auth0/tree/v2.13.0) (2018-09-28) @@ -21,7 +517,7 @@ **Added** -* Add id_token validation (HS256 and RS256) [\#295](https://github.com/auth0/node-auth0/pull/295) ([luisrudge](https://github.com/luisrudge)) +- Add id_token validation (HS256 and RS256) [\#295](https://github.com/auth0/node-auth0/pull/295) ([luisrudge](https://github.com/luisrudge)) ## [v2.12.0](https://github.com/auth0/node-auth0/tree/v2.12.0) (2018-08-09) @@ -29,8 +525,8 @@ **Added** -* Added authorizationCodeGrant method to OAuthAuthenticator [\#290](https://github.com/auth0/node-auth0/pull/290) ([cwurtz](https://github.com/cwurtz)) -* Add Guardian Enrollments endpoints [\#278](https://github.com/auth0/node-auth0/pull/278) ([fmedinac](https://github.com/fmedinac)) +- Added authorizationCodeGrant method to OAuthAuthenticator [\#290](https://github.com/auth0/node-auth0/pull/290) ([cwurtz](https://github.com/cwurtz)) +- Add Guardian Enrollments endpoints [\#278](https://github.com/auth0/node-auth0/pull/278) ([fmedinac](https://github.com/fmedinac)) ## [v2.11.0](https://github.com/auth0/node-auth0/tree/v2.11.0) (2018-07-25) @@ -38,12 +534,12 @@ **Added** -* Added Pagination Docs for a Client Grants, Resouce Servers and Rules [\#282](https://github.com/auth0/node-auth0/pull/282) ([cocojoe](https://github.com/cocojoe)) -* Added rules config methods [\#227](https://github.com/auth0/node-auth0/pull/227) ([dctoon](https://github.com/dctoon)) +- Added Pagination Docs for a Client Grants, Resouce Servers and Rules [\#282](https://github.com/auth0/node-auth0/pull/282) ([cocojoe](https://github.com/cocojoe)) +- Added rules config methods [\#227](https://github.com/auth0/node-auth0/pull/227) ([dctoon](https://github.com/dctoon)) **Fixed** -* Get access token before importing users [\#267](https://github.com/auth0/node-auth0/pull/267) ([Floppy](https://github.com/Floppy)) +- Get access token before importing users [\#267](https://github.com/auth0/node-auth0/pull/267) ([Floppy](https://github.com/Floppy)) ## [v2.10.0](https://github.com/auth0/node-auth0/tree/v2.10.0) (2018-05-29) @@ -51,11 +547,11 @@ **Added** -* Adding pagination docs for clients/connections [\#268](https://github.com/auth0/node-auth0/pull/268) ([luisrudge](https://github.com/luisrudge)) +- Adding pagination docs for clients/connections [\#268](https://github.com/auth0/node-auth0/pull/268) ([luisrudge](https://github.com/luisrudge)) **Fixed** -* Fix deleteUserMultifactor naming [\#259](https://github.com/auth0/node-auth0/pull/259) ([luisrudge](https://github.com/luisrudge)) +- Fix deleteUserMultifactor naming [\#259](https://github.com/auth0/node-auth0/pull/259) ([luisrudge](https://github.com/luisrudge)) ## [v2.9.3](https://github.com/auth0/node-auth0/tree/v2.9.3) (2018-03-01) @@ -63,7 +559,7 @@ **Fixed** -* Add client secret to passwordGrant [\#217](https://github.com/auth0/node-auth0/pull/217) ([luisrudge](https://github.com/luisrudge)) +- Add client secret to passwordGrant [\#217](https://github.com/auth0/node-auth0/pull/217) ([luisrudge](https://github.com/luisrudge)) ## [v2.9.2](https://github.com/auth0/node-auth0/tree/v2.9.2) (2018-01-16) @@ -71,7 +567,7 @@ **Security** -* Update rest facade [\#232](https://github.com/auth0/node-auth0/pull/232) ([luisrudge](https://github.com/luisrudge)) +- Update rest facade [\#232](https://github.com/auth0/node-auth0/pull/232) ([luisrudge](https://github.com/luisrudge)) ## [v2.9.1](https://github.com/auth0/node-auth0/tree/v2.9.1) (2017-12-08) @@ -79,7 +575,7 @@ **Fixed** -* fixed missing data object error [\#224](https://github.com/auth0/node-auth0/pull/224) ([dctoon](https://github.com/dctoon)) +- fixed missing data object error [\#224](https://github.com/auth0/node-auth0/pull/224) ([dctoon](https://github.com/dctoon)) ## [v2.9.0](https://github.com/auth0/node-auth0/tree/v2.9.0) (2017-12-07) @@ -87,8 +583,8 @@ **Added** -* Added support for /users-by-email method. [\#218](https://github.com/auth0/node-auth0/pull/218) ([kopertop](https://github.com/kopertop)) -* Add retry functionality for management api requests [\#215](https://github.com/auth0/node-auth0/pull/215) ([dctoon](https://github.com/dctoon)) +- Added support for /users-by-email method. [\#218](https://github.com/auth0/node-auth0/pull/218) ([kopertop](https://github.com/kopertop)) +- Add retry functionality for management api requests [\#215](https://github.com/auth0/node-auth0/pull/215) ([dctoon](https://github.com/dctoon)) ## [v2.8.0](https://github.com/auth0/node-auth0/tree/v2.8.0) (2017-09-30) @@ -96,11 +592,11 @@ **Added** -* Added tokenProvider functionality [\#196](https://github.com/auth0/node-auth0/pull/196) ([dctoon](https://github.com/dctoon)) +- Added tokenProvider functionality [\#196](https://github.com/auth0/node-auth0/pull/196) ([dctoon](https://github.com/dctoon)) **Fixed** -* Fix wrapPropertyMethod mistake for updateClientGrant [\#202](https://github.com/auth0/node-auth0/pull/202) ([danedmunds](https://github.com/danedmunds)) +- Fix wrapPropertyMethod mistake for updateClientGrant [\#202](https://github.com/auth0/node-auth0/pull/202) ([danedmunds](https://github.com/danedmunds)) ## [v2.7.1](https://github.com/auth0/node-auth0/tree/v2.7.1) (2017-09-30) @@ -108,11 +604,11 @@ **Fixed** -* Fix auth/users.getInfo to return JSON (fixes #158) [\#192](https://github.com/auth0/node-auth0/pull/192) ([pilwon](https://github.com/pilwon)) +- Fix auth/users.getInfo to return JSON (fixes #158) [\#192](https://github.com/auth0/node-auth0/pull/192) ([pilwon](https://github.com/pilwon)) **Security** -* Update request to address ReDoS vulnerability [\#206](https://github.com/auth0/node-auth0/pull/206) ([dancrumb](https://github.com/dancrumb)) +- Update request to address ReDoS vulnerability [\#206](https://github.com/auth0/node-auth0/pull/206) ([dancrumb](https://github.com/dancrumb)) ## [v2.7.0](https://github.com/auth0/node-auth0/tree/v2.7.0) (2017-06-28) @@ -120,16 +616,16 @@ **Added** -* Add password grant method [\#189](https://github.com/auth0/node-auth0/pull/189) ([hzalaz](https://github.com/hzalaz)) -* Retrieve a user's Guardian enrollments [\#181](https://github.com/auth0/node-auth0/pull/181) ([joshuaali](https://github.com/joshuaali)) -* Add get user logs [\#176](https://github.com/auth0/node-auth0/pull/176) ([amiram](https://github.com/amiram)) +- Add password grant method [\#189](https://github.com/auth0/node-auth0/pull/189) ([hzalaz](https://github.com/hzalaz)) +- Retrieve a user's Guardian enrollments [\#181](https://github.com/auth0/node-auth0/pull/181) ([joshuaali](https://github.com/joshuaali)) +- Add get user logs [\#176](https://github.com/auth0/node-auth0/pull/176) ([amiram](https://github.com/amiram)) **Changed** -* Update packages and utilize error classes from rest-facade correctly (Fixes #154) [\#183](https://github.com/auth0/node-auth0/pull/183) ([charsleysa](https://github.com/charsleysa)) +- Update packages and utilize error classes from rest-facade correctly (Fixes #154) [\#183](https://github.com/auth0/node-auth0/pull/183) ([charsleysa](https://github.com/charsleysa)) **Fixed** -* Fix impersonation to send AT in the params. [\#190](https://github.com/auth0/node-auth0/pull/190) ([hzalaz](https://github.com/hzalaz)) -* Fixed minor typo in DatabaseAuthenticator module [\#184](https://github.com/auth0/node-auth0/pull/184) ([scostello-paanalytics](https://github.com/scostello-paanalytics)) -* fix: avoid possible prototype override protection bypass [\#170](https://github.com/auth0/node-auth0/pull/170) ([AlmaasAre](https://github.com/AlmaasAre)) +- Fix impersonation to send AT in the params. [\#190](https://github.com/auth0/node-auth0/pull/190) ([hzalaz](https://github.com/hzalaz)) +- Fixed minor typo in DatabaseAuthenticator module [\#184](https://github.com/auth0/node-auth0/pull/184) ([scostello-paanalytics](https://github.com/scostello-paanalytics)) +- fix: avoid possible prototype override protection bypass [\#170](https://github.com/auth0/node-auth0/pull/170) ([AlmaasAre](https://github.com/AlmaasAre)) diff --git a/EXAMPLES.md b/EXAMPLES.md new file mode 100644 index 000000000..da01a0fa8 --- /dev/null +++ b/EXAMPLES.md @@ -0,0 +1,69 @@ +# Examples + +## Automatic Management API Token Retrieval + +To **automatically** obtain a Management API token via the ManagementClient, you can specify the parameters `clientId`, `clientSecret` (use a Non Interactive Client) and optionally `scope`. +Behind the scenes the Client Credentials Grant is used to obtain the `access_token` and is by default cached for the duration of the returned `expires_in` value. + +```js +var ManagementClient = require('auth0').ManagementClient; +var auth0 = new ManagementClient({ + domain: '{YOUR_ACCOUNT}.auth0.com', + clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}', + clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}', + scope: 'read:users update:users', +}); +``` + +> Make sure your `clientId` is allowed to request tokens from Management API in [Auth0 Dashboard](https://manage.auth0.com/#/apis) + +### Obtaining Management API Token from Node.js backend + +To obtain a Management API token from your node backend, you can use Client Credentials Grant using your registered Auth0 Non Interactive Clients + +```js +var AuthenticationClient = require('auth0').AuthenticationClient; + +var auth0 = new AuthenticationClient({ + domain: '{YOUR_ACCOUNT}.auth0.com', + clientId: '{CLIENT_ID}', + clientSecret: '{CLIENT_SECRET}', +}); + +auth0.clientCredentialsGrant( + { + audience: 'https://{YOUR_ACCOUNT}.auth0.com/api/v2/', + scope: '{MANAGEMENT_API_SCOPES}', + }, + function (err, response) { + if (err) { + // Handle error. + } + console.log(response.access_token); + } +); +``` + +### Promises and callback support + +All methods can be used with promises or callbacks, when a callback argument is provided no promise will be returned. + +```js +// Using callbacks. +management.getUsers(function (err, users) { + if (err) { + // handle error. + } + console.log(users); +}); + +// Using promises. +management + .getUsers() + .then(function (users) { + console.log(users); + }) + .catch(function (err) { + // Handle error. + }); +``` diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 000000000..6ac0ce2c2 --- /dev/null +++ b/FAQ.md @@ -0,0 +1,21 @@ +# Frequently Asked Questions + +Below are a number of questions or issues that have arisen from using the SDK. + +## Does this library have type definitions? + +The types for this library are currently maintained by the community at [Definitely Typed](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/auth0). The team is planning taking ownership of this library as discussed in https://github.com/auth0/node-auth0/issues/572. + +### Getting `Error: Can't resolve 'superagent-proxy'` when bundling with Webpack + +We have a dependency on `rest-facade` which `require`s but doesn't include `superagent-proxy`. This SDK doesn't support proxies, so this dependency is not required. To workaround this you can add the following to your `webpack.config.js`: + +``` +resolve: { + alias: { + 'superagent-proxy': false + } +} +``` + +Or install `superagent-proxy` yourself. diff --git a/README.md b/README.md index 38f19d34a..7ac0875ea 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,39 @@ -# node-auth0 +![Node.js client library for Auth0](https://cdn.auth0.com/website/sdks/banner/node-auth0-banner.png) -[![Build Status][circleci-image]][circleci-url] -[![NPM version][npm-image]][npm-url] -[![Coverage][codecov-image]][codecov-url] -[![License][license-image]][license-url] -[![Downloads][downloads-image]][downloads-url] +![Release](https://img.shields.io/npm/v/auth0) +[![Codecov](https://img.shields.io/codecov/c/github/auth0/node-auth0)](https://codecov.io/gh/auth0/node-auth0) +![Downloads](https://img.shields.io/npm/dw/auth0) +[![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://opensource.org/licenses/MIT) +![CircleCI](https://img.shields.io/circleci/build/github/auth0/node-auth0) -Node.js client library for the [Auth0](https://auth0.com) platform. +📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💻 [API Reference](#api-reference) - 💬 [Feedback](#feedback) -## Installation +## Documentation -```bash - npm install auth0 -``` +- [FAQs](https://github.com/auth0/node-auth0/blob/master/FAQ.md) - frequently asked questions about node-auth0. +- [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0 -## Documentation +## Getting Started + +### Requirements -You can find this library documentation in this [page](http://auth0.github.io/node-auth0/). +This library supports the following tooling versions: + +- Node.js: `>=8.3.0` + +### Installation + +Using [npm](https://npmjs.org) in your project directory run the following command: + +```bash +npm install auth0 +``` -For more information about [auth0](http://auth0.com) check our [documentation page](http://docs.auth0.com/). +### Configure the SDK -## Authentication API Client +#### Authentication API Client -This client must be used to access Auth0's [Authentication API](https://auth0.com/docs/auth-api). +This client must be used to access Auth0's [Authentication API](https://auth0.com/docs/api/authentication). The **AuthenticationClient** constructor takes an _optional_ client ID, if specified it will be used as default value for all endpoints that accept a client ID. @@ -31,11 +42,13 @@ var AuthenticationClient = require('auth0').AuthenticationClient; var auth0 = new AuthenticationClient({ domain: '{YOUR_ACCOUNT}.auth0.com', - clientId: '{OPTIONAL_CLIENT_ID}' + clientId: '{OPTIONAL_CLIENT_ID}', }); ``` -## Management API Client +#### Management API Client + +> Note: When using the ManagementClient in a browser you should set `telemetry: false`. The Auth0 Management API is meant to be used by back-end servers or trusted parties performing administrative tasks. Generally speaking, anything that can be done through the Auth0 dashboard (and more) can also be done through this API. @@ -46,115 +59,46 @@ var ManagementClient = require('auth0').ManagementClient; var management = new ManagementClient({ token: '{YOUR_API_V2_TOKEN}', - domain: '{YOUR_ACCOUNT}.auth0.com' -}); -``` - -> Note: When using at browser you should use `telemetry: false`. - -To obtain **automatically** a Management API token via the ManagementClient, you can specify the parameters `clientId`, `clientSecret` (use a Non Interactive Client) and optionally `scope`. -Behind the scenes the Client Credentials Grant is used to obtain the `access_token` and is by default cached for the duration of the returned `expires_in` value. - -```js -var ManagementClient = require('auth0').ManagementClient; -var auth0 = new ManagementClient({ - domain: '{YOUR_ACCOUNT}.auth0.com', - clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}', - clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}', - scope: 'read:users update:users' -}); -``` - -> Make sure your ClientId is allowed to request tokens from Management API in [Auth0 Dashboard](https://manage.auth0.com/#/apis) - -To obtain a Management API token from your node backend, you can use Client Credentials Grant using your registered Auth0 Non Interactive Clients - -```js -var AuthenticationClient = require('auth0').AuthenticationClient; - -var auth0 = new AuthenticationClient({ domain: '{YOUR_ACCOUNT}.auth0.com', - clientId: '{CLIENT_ID}', - clientSecret: '{CLIENT_SECRET}' -}); - -auth0.clientCredentialsGrant( - { - audience: 'https://{YOUR_ACCOUNT}.auth0.com/api/v2/', - scope: '{MANAGEMENT_API_SCOPES}' - }, - function(err, response) { - if (err) { - // Handle error. - } - console.log(response.access_token); - } -); -``` - -Also you can request a token when the user authenticates using any of our client side SDKs, e.g. [auth0.js](https://github.com/auth0/auth0.js). - -## Promises and callbacks - -Be aware that all methods can be used with promises or callbacks. However, when a callback is provided no promise will be returned. - -```js -// Using callbacks. -management.getUsers(function(err, users) { - if (err) { - // handle error. - } - console.log(users); }); - -// Using promises. -management - .getUsers() - .then(function(users) { - console.log(users); - }) - .catch(function(err) { - // Handle error. - }); ``` -## What is Auth0? +For other examples see the [EXAMPLES.md](https://github.com/auth0/node-auth0/blob/master/EXAMPLES.md) document. -Auth0 helps you to: +## API Reference -* Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**. -* Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**. -* Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user. -* Support for generating signed [Json Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely. -* Analytics of how, when and where users are logging in. -* Pull data from other sources and add it to the user profile, through [JavaScript rules](https://docs.auth0.com/rules). +- [AuthenticationClient](https://auth0.github.io/node-auth0/AuthenticationClient.html) +- [ManagementClient](https://auth0.github.io/node-auth0/ManagementClient.html) -## Create a free Auth0 Account +## Feedback -1. Go to [Auth0](https://auth0.com) and click "Try Auth0 for Free". -2. Use Google, GitHub or Microsoft Account to login. +### Contributing -## Issue Reporting +We appreciate feedback and contribution to this repo! Before you get started, please see the following: -If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues. +- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md) +- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) -## Author +### Raise an issue -[Auth0](https://auth0.com) +To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/node-auth0/issues). -## License +### Vulnerability Reporting -This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info. +Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues. - +## What is Auth0? -[npm-image]: https://img.shields.io/npm/v/auth0.svg?style=flat-square -[npm-url]: https://npmjs.org/package/auth0 -[circleci-image]: http://img.shields.io/circleci/project/github/auth0/node-auth0.svg?branch=master&style=flat-square -[circleci-url]: https://circleci.com/gh/auth0/node-auth0 -[codecov-image]: https://img.shields.io/codecov/c/github/auth0/node-auth0.svg?style=flat-square -[codecov-url]: https://codecov.io/github/auth0/node-auth0?branch=master -[license-image]: http://img.shields.io/npm/l/auth0.svg?style=flat-square -[license-url]: #license -[downloads-image]: http://img.shields.io/npm/dm/auth0.svg?style=flat-square -[downloads-url]: https://npmjs.org/package/auth0 +

+ + + + Auth0 Logo + +

+

+ Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0? +

+

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

diff --git a/codecov.yml b/codecov.yml index b8422ba78..53cea3867 100644 --- a/codecov.yml +++ b/codecov.yml @@ -5,6 +5,7 @@ coverage: status: patch: default: + threshold: 50 if_no_uploads: error changes: true project: @@ -15,4 +16,4 @@ coverage: - test/ - docs/ - examples/ -comment: false \ No newline at end of file +comment: false diff --git a/docs/ActionsManager.html b/docs/ActionsManager.html new file mode 100644 index 000000000..b136ea88d --- /dev/null +++ b/docs/ActionsManager.html @@ -0,0 +1,4946 @@ + + + + + + ActionsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

ActionsManager

+ + + + + + + +
+ +
+ +

+ ActionsManager +

+ +

Actions provide a way to extend +Auth0 flows with custom logic. +See the Actions documentation for more information.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new ActionsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Actions endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new Action.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Action data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.actions.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Action created.
+});
+ +
+ +
+ + +
+ + + +

createVersion(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Action Version. In general, updating an action and then +deploying it is the preferred way of creating an action version, but +this operation is supported as a way of creating versions without +updating the action's code (which can be useful in some CI/CD scenarios).

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

ActionVersion parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: ACTION_ID };
+management.actions.createActionVersion(params, data, function (err, actionVersion) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing action. Deleting an Action deletes all the action's versions

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.actions.delete({ id: ACTION_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Action deleted.
+});
+ +
+ +
+ + +
+ + + +

deploy(params, cbopt) → {Promise|undefined}

+ + + + + +
+

deploy an Action. +The action must be in a state of 'built' before it can be deployed.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: ACTION_ID};
+mangement.actions.deploy(params, function (err, actionVersion) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

deployVersion(params, cbopt) → {Promise|undefined}

+ + + + + +
+

deploy an Action Version to roll back to a previous version.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action ID.

+ +
version_id + + +string + + + + +

Action ID.

+ +
update_draft + + +boolean + + + + +

Update draft

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: ACTION_ID, version_id: VERSION_ID };
+management.actions.deployVersion(params, function (err, actionVersion) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 action.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.actions.get({ id: ACTION_ID }, function (err, action) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(action);
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all actions.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Actions parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
triggerId + + +string + + + + + + <optional>
+ + + + + +
+

The trigger ID of the actions to retrieve.

+ +
actionName + + +string + + + + + + <optional>
+ + + + + +
+

The name of the actions to retrieve.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0,
+  triggerId:'TRIGGER_ID',
+  actionName: 'ACTION_NAME'
+};
+
+management.actions.getAll(params, function (err, actions) {
+  console.log(actions.length);
+});
+ +
+ +
+ + +
+ + + +

getAllTriggers(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Triggers.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Actions parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.actions.getAllTriggers(params, function (err, actions) {
+  console.log(actions.length);
+});
+ +
+ +
+ + +
+ + + +

getExecution(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an execution by ID.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action Execution parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action Execution ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.actions.getExecution({ execution_id: EXECUTION_ID }, function (err, action) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(ActionExecution);
+});
+ +
+ +
+ + +
+ + + +

getTriggerBindings(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the actions bound to a trigger .

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Actions Binding parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
trigger_id + + +string + + + + +

Actions Trigger ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { trigger_id: TRIGGER_ID };
+
+// Using auth0 instance.
+management.actions.getTriggerBindings(params, function (err, bindings) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(bindings.length);  // 2
+});
+ +
+ +
+ + +
+ + + +

getVersion(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Action Version.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action ID.

+ +
version_id + + +string + + + + +

ActionVersion ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: ACTION_ID, version_id: VERSION_ID };
+management.actions.getVersion(params, function (err, actionVersion) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

getVersions(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all action versions

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

ActionVersions parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
id + + +string + + + + + + <optional>
+ + + + + +
+

Action ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.actions.getVersions({ id: ACTION_ID }, function (err, actionVersions) {
+  console.log(actionVersions.length);
+});
+ +
+ +
+ + +
+ + + +

test(params, payload, cbopt) → {Promise|undefined}

+ + + + + +
+

test an Action.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action ID.

+ +
+ + +
payload + + +object + + + + + + + + + + +

Payload represents the entire structure necessary to test a particular trigger

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: ACTION_ID};
+management.actions.test(params, payload, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing action.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Action parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Action ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated action data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'new-name' };
+var params = { id: ACTION_ID };
+
+// Using auth0 instance.
+management.updateAction(params, data, function (err, action) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(action.name);  // 'new-name'
+});
+
+// Using the Actions manager directly.
+management.actions.update(params, data, function (err, action) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(action.name);  // 'new-name'
+});
+ +
+ +
+ + +
+ + + +

updateTriggerBindings(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the actions bound to a trigger .

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Actions Binding parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
trigger_id + + +string + + + + +

Actions Trigger ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

bindings array

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { bindings: [{ id_type: "action_id", id_value: ACTION_ID1},{id_type: "action_name", id_value: ACTION_NAME2}];
+var params = { trigger_id: TRIGGER_ID };
+
+// Using auth0 instance.
+management.actions.updateTriggerBindings(params, data, function (err, bindings) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(bindings.length);  // 2
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/AttackProtectionManager.html b/docs/AttackProtectionManager.html new file mode 100644 index 000000000..cc3f9c185 --- /dev/null +++ b/docs/AttackProtectionManager.html @@ -0,0 +1,1816 @@ + + + + + + AttackProtectionManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

AttackProtectionManager

+ + + + + + + +
+ +
+ +

+ AttackProtectionManager +

+ +

Abstracts interaction with the attack-protection endpoints.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new AttackProtectionManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
tokenProvider + + +object + + + + + + <optional>
+ + + + + +
+

Management API Token Provider

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

getBreachedPasswordDetectionConfig(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the Breached Password Detection configuration.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Breached password detection parameters (leave empty).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.attackProtection.getBreachedPasswordDetectionConfig(params, function (err, breachedPasswordDetectionConfig) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Access breached password detection configuration
+  console.log(breachedPasswordDetectionConfig);
+});
+ +
+ +
+ + +
+ + + +

getBruteForceConfig(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the Brute Force Protection configuration.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Brute force parameters (leave empty).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.attackProtection.getBruteForceConfig(params, function (err, bruteForceConfig) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Brute force config
+  console.log(bruteForceConfig);
+});
+ +
+ +
+ + +
+ + + +

getSuspiciousIpThrottlingConfig(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the Suspicious IP Throttling configuration.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Suspicious IP throttling parameters (leave empty).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.attackProtection.getSuspiciousIpThrottlingConfig(params, function (err, suspiciousIpThrottlingConfig) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Access suspicious IP throttling configuration
+  console.log(suspiciousIpThrottlingConfig);
+});
+ +
+ +
+ + +
+ + + +

updateBreachedPasswordDetectionConfig(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the breached password detection configuration.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Breached password detection parameters (leave empty).

+ +
data + + +object + + + + + + + + + + +

Updated breached password detection configuration.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.attackProtection.updateBreachedPasswordDetectionConfig(params, data, function (err, breachedPasswordDetectionConfig) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Access breached password detection configuration
+  console.log(breachedPasswordDetectionConfig);
+});
+ +
+ +
+ + +
+ + + +

updateBruteForceConfig(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the Brute Force Protection configuration.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Brute force parameters (leave empty).

+ +
data + + +object + + + + + + + + + + +

Updated brute force configuration.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.attackProtection.updateBruteForceConfig(params, data, function (err, bruteForceConfig) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Brute force config
+  console.log(bruteForceConfig);
+});
+ +
+ +
+ + +
+ + + +

updateSuspiciousIpThrottlingConfig(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the Suspicious IP Throttling configuration.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Suspicious IP throttling parameters (leave empty).

+ +
data + + +object + + + + + + + + + + +

Updated suspicious IP throttling configuration.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.attackProtection.updateSuspiciousIpThrottlingConfig(params, data, function (err, suspiciousIpThrottlingConfig) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Access suspicious IP throttling configuration
+  console.log(suspiciousIpThrottlingConfig);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/AuthenticationClient.html b/docs/AuthenticationClient.html new file mode 100644 index 000000000..2bbb44579 --- /dev/null +++ b/docs/AuthenticationClient.html @@ -0,0 +1,4631 @@ + + + + + + AuthenticationClient - Documentation + + + + + + + + + + + + + + + + + +
+ +

AuthenticationClient

+ + + + + + + +
+ +
+ +

+ AuthenticationClient +

+ +

Authentication API SDK.

+

This client must used to access Auth0's Authentication API.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new AuthenticationClient(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

Options for the Authentication Client SDK.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
domain + + +string + + + + + + + + + + +

AuthenticationClient server domain.

+ +
clientId + + +string + + + + + + <optional>
+ + + + + +
+

Default client ID.

+ +
clientSecret + + +string + + + + + + <optional>
+ + + + + +
+

Default client Secret.

+ +
supportedAlgorithms + + +string + + + + + + <optional>
+ + + + + +
+

Algorithms that your application expects to receive

+ +
__bypassIdTokenValidation + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether the id_token should be validated or not

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Additional headers that will be added to the outgoing requests.

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+
Example
+ +

+ The AuthenticationClient constructor takes an optional client + ID, if specified it will be used as default value for all endpoints that + accept a client ID. +

+ +
var AuthenticationClient = require('auth0').AuthenticationClient;
+var auth0 = new AuthenticationClient({
+  domain: '{YOUR_ACCOUNT}.auth0.com',
+  clientId: '{OPTIONAL_CLIENT_ID}'
+});
+ +
+ +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

database :DatabaseAuthenticator

+ + + + +
+

Database authenticator.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

oauth :OAuthAuthenticator

+ + + + +
+

OAuth authenticator.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

passwordless :PasswordlessAuthenticator

+ + + + +
+

Passwordless authenticator.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

tokens :TokensManager

+ + + + +
+

Tokens manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

users :UsersManager

+ + + + +
+

Users manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

changePassword(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Change password using a database or active directory service.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

User data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +string + + + + +

User email.

+ +
password + + +string + + + + +

User password.

+ +
connection + + +string + + + + +

Identity provider for the user.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user email, the connection specified and the new password to + use, Auth0 will send a forgot password email. Once the user clicks on the + confirm password change link, the new password specified in this POST will + be set to this user. Find more information in the + + API Docs. +

+ +
var data = {
+  email: '{EMAIL}',
+  password: '{PASSWORD}',
+  connection: 'Username-Password-Authentication'
+};
+
+auth0.changePassword(data, function (err, message) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(message);
+});
+ +
+ +
+ + +
+ + + +

clientCredentialsGrant(options) → {Promise|undefined}

+ + + + + +
+

Gets an access token using the client credentials grant flow.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
scope + + +string + + + + + + <optional>
+ + + + + +
+

scopes to request to be added to the returned access token

+ +
audience + + +string + + + + + + <optional>
+ + + + + +
+

audience or identifier of the API where the access token will be used, e.g. Auth0 Management API

+ +
+ + +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Gets an access token using the client credentials grant flow. Find more information in the + API Docs. +

+ +
auth0.clientCredentialsGrant({
+  audience: 'https://tenant.auth0.com/api/v2/',
+  scope: 'read:users update:users'
+}, function (err, response) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(response);
+});
+ +
+ +
+ + +
+ + + +

getDelegationToken(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Exchange the token of the logged in user with a token that is valid to call +the API (signed with the API secret).

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Token data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id_token + + +string + + + + +

The user ID token.

+ +
api_type + + +string + + + + +

The API type (aws, firebase, etc).

+ +
target + + +string + + + + +

The target client ID.

+ +
grant_type + + +string + + + + +

The grant type.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given an existing token, this endpoint will generate a new token signed + with the target client secret. This is used to flow the identity of the + user from the application to an API or across different APIs that are + protected with different secrets. Find more information in the + API Docs. +

+ +
var data = {
+  id_token: '{ID_TOKEN}',
+  api_type: 'app',
+  target: '{TARGET}',
+  grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer'
+};
+
+auth0.getDelegationToken(data, function (err, token) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(token);
+});
+ +
+ +
+ + +
+ + + +

getProfile(accessToken) → {Promise|undefined}

+ + + + + +
+

Given an access token get the user profile linked to it.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
accessToken + + +string + + + + +

The user access token.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Get the user information based on the Auth0 access token (obtained during + login). Find more information in the + API Docs. +

+ +
auth0.getProfile(data, function (err, userInfo) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(userInfo);
+});
+ +
+ +
+ + +
+ + + +

passwordGrant(userData, optionsopt) → {Promise|undefined}

+ + + + + +
+

Sign in using a username and password

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
username + + +string + + + + + + + + + + +

Username.

+ +
password + + +string + + + + + + + + + + +

User password.

+ +
realm + + +string + + + + + + <optional>
+ + + + + +
+

Name of the realm to use to authenticate or the connection name

+ +
+ + +
options + + +object + + + + + + <optional>
+ + + + + +
+

Additional options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
forwardedFor + + +string + + + + + + <optional>
+ + + + + +
+

Value to be used for auth0-forwarded-for header

+ +
+ + +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user's credentials perform the OAuth password grant + or Password Realm grant if a realm is provided, + it will return a JSON with the access_token and id_token. + More information in the + + API Docs + . +

+ +
var data = {
+  client_id: '{CLIENT_ID}',  // Optional field.
+  username: '{USERNAME}',
+  password: '{PASSWORD}'
+  realm: '{CONNECTION_NAME}', // Optional field.
+  scope: 'openid'  // Optional field.
+};
+
+auth0.passwordGrant(data, function (err, userData) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(userData);
+});
+ +
+ +
+ + +
+ + + +

refreshToken(userData) → {Promise|undefined}

+ + + + + +
+

Sign in using a refresh token

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
userData + + +object + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
refresh_token + + +string + + + + +

Refresh token.

+ +
+ + +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given a refresh token from a previous authentication request, + it will return a JSON with the access_token and id_token. + More information in the + + API Docs + . +

+ +
var data = {
+  client_id: '{CLIENT_ID}', // Optional field.
+  refresh_token: '{REFRESH_TOKEN}',
+};
+
+auth0.refreshToken(data, function (err, userData) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(userData);
+});
+ +
+ +
+ + +
+ + + +

requestChangePasswordEmail(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Request a change password email using a database or active directory service.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

User data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +string + + + + +

User email.

+ +
connection + + +string + + + + +

Identity provider for the user.

+ +
client_id + + +string + + + + +

Client ID of the Application requesting the password change, to be included in the email template.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user email, the connection specified, Auth0 will send a change + password email. once the user clicks on the confirm password change link, + the new password specified in this POST will be set to this user. Find more + information in the var data = { + email: '{EMAIL}', + connection: 'Username-Password-Authentication', + client_id: 'OS1VzKTVjizL0VCc9Hx2ae2aTPXWy6BD' +}; + +auth0.requestChangePasswordEmail(data, function (err, message) { + if (err) { + // Handle error. + } + + console.log(message); +}); + +

+ +
+ + +
+ + + +

requestEmailCode(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Start passwordless flow sending an email.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

User data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
email + + +string + + + + + + + + + + +

User email address.

+ +
authParams + + +object + + + + + + <optional>
+ + + + + +
+

Authentication parameters.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user `email` address, it will send an email with a verification + code. You can then authenticate with this user using the `/oauth/ro` + endpoint using the email as username and the code as password. + + Find more information in the + API Docs +

+ +
var data = {
+  email: '{EMAIL}',
+  authParams: {} // Optional auth params.
+};
+
+auth0.requestEmailCode(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+};
+ +
+ +
+ + +
+ + + + + + + + + +
+

Start passwordless flow sending an email.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

User data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
email + + +string + + + + + + + + + + +

User email address.

+ +
authParams + + +object + + + + + + <optional>
+ + + + + +
+

Authentication parameters.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user `email` address, it will send an email with a link. You can + then authenticate with this user opening the link and he will be + automatically logged in to the application. Optionally, you can + append/override parameters to the link (like `scope`, `redirect_uri`, + `protocol`, `response_type`, etc.) using `authParams` object. + + Find more information in the + API Docs +

+ +
var data = {
+  email: '{EMAIL}',
+  authParams: {} // Optional auth params.
+};
+
+auth0.requestMagicLink(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+};
+ +
+ +
+ + +
+ + + +

requestSMSCode(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Start passwordless flow sending an SMS.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

User data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
phone_number + + +string + + + + +

The user phone number.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user `phone_number`, it will send a SMS message with a + verification code. You can then authenticate with this user using the + `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as + `password`: +

+ +
var data = {
+  phone_number: '{PHONE}'
+};
+
+auth0.requestSMSCode(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+});
+ +
+ +
+ + +
+ + + +

verifyEmailCode(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Verify the given OTP which was sent on the given email.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +string + + + + +

Email.

+ +
otp + + +string + + + + +

Verification code.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +

+ Given the user credentials (`email` and `otp`), authenticates + with the provider using the `/oauth/token` endpoint. Upon successful + authentication, returns a JSON object containing the `access_token` and + `id_token`. +

+ +
var data = {
+  email: '{EMAIL}',
+  otp: '{VERIFICATION_CODE}'
+};
+
+auth0.verifyEmailCode(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +

+ The user data object has the following structure. +

+ +
{
+  id_token: String,
+  access_token: String,
+  token_type: String
+}
+ +
+ +
+ + +
+ + + +

verifySMSCode(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Sign in with the given user credentials.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
username + + +string + + + + +

Phone number.

+ +
otp + + +string + + + + +

Verification code. Use this instead of password to use the /oauth/token endpoint.

+ +
password + + +string + + + + +

Verification code. Use this instead of otp to use the /oauth/ro endpoint.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +

+ Given the user credentials (`phone_number` and `otp`), authenticates + with the provider using the `/oauth/token` endpoint. Upon successful + authentication, returns a JSON object containing the `access_token` and + `id_token`. +

+ +
var data = {
+  username: '{PHONE_NUMBER}'
+  otp: '{VERIFICATION_CODE}'
+};
+
+auth0.verifySMSCode(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +

+ Given the user credentials (`phone_number` and `password`), authenticates + with the provider using the deprecated `/oauth/ro` endpoint. Upon successful + authentication, returns a JSON object containing the `access_token` and + `id_token`. +

+ +
var data = {
+  username: '{PHONE_NUMBER}',
+  password: '{VERIFICATION_CODE}'
+};
+
+auth0.verifySMSCode(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +

+ The user data object has the following structure. +

+ +
{
+  id_token: String,
+  access_token: String,
+  token_type: String
+}
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/BlacklistedTokensManager.html b/docs/BlacklistedTokensManager.html new file mode 100644 index 000000000..12393c8d4 --- /dev/null +++ b/docs/BlacklistedTokensManager.html @@ -0,0 +1,924 @@ + + + + + + BlacklistedTokensManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

BlacklistedTokensManager

+ + + + + + + +
+ +
+ +

+ BlacklistedTokensManager +

+ +

The BlacklistedTokensManager class provides methods to retrieve the list of +blacklisted tokens and blacklist new ones..

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new BlacklistedTokensManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Blacklisted Tokens endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

add(token, cbopt) → {Promise|undefined}

+ + + + + +
+

Blacklist a new token.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
token + + +object + + + + + + + + + + +

Token data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
aud + + +string + + + + +

Audience (your app client ID).

+ +
jti + + +string + + + + +

The JWT ID claim.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var token = {
+ aud: 'aud',
+ jti: 'jti'
+};
+
+management.blacklistedTokens.add(token, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Token blacklisted.
+});
+ +
+ +
+ + +
+ + + +

getAll(cbopt) → {Promise|undefined}

+ + + + + +
+

Get all blacklisted tokens.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.blacklistedTokens.getAll(function (err, tokens) {
+  console.log(tokens.length);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/BrandingManager.html b/docs/BrandingManager.html new file mode 100644 index 000000000..20ff6decf --- /dev/null +++ b/docs/BrandingManager.html @@ -0,0 +1,3106 @@ + + + + + + BrandingManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

BrandingManager

+ + + + + + + +
+ +
+ +

+ BrandingManager +

+ +

Manages settings related to branding.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new BrandingManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

brandingTemplates :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Branding new universal login template endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

brandingThemes :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Branding theme endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Branding endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

createTheme(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new theme.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

theme data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.branding.createTheme(data, function (err, theme) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Theme created.
+  console.log(theme);
+});
+ +
+ +
+ + +
+ + + +

deleteTheme(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a theme.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Theme parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +object + + + + +

Theme identifier.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: THEME_ID };
+
+management.branding.deleteTheme(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Theme deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteUniversalLoginTemplate(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete the new universal login template (revert to default).

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters (leavy empty).

+ +
data + + +object + + + + + + + + + + +

Branding data (leave empty).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.branding.deleteUniversalLoginTemplate(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

getDefaultTheme(cbopt) → {Promise|undefined}

+ + + + + +
+

Get the default new universal login theme.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.branding.getDefaultTheme(function (err, theme) {
+  if (err) {
+    // Handle error.
+  }
+
+   // Theme
+   console.log(theme);
+});
+ +
+ +
+ + +
+ + + +

getSettings(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the branding settings..

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters.

+ +
data + + +object + + + + + + + + + + +

Branding data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.branding.getSettings(data, function (err, branding) {
+  if (err) {
+    // Handle error.
+  }
+
+// Branding
+   console.log(branding);
+});
+ +
+ +
+ + +
+ + + +

getTheme(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the new universal login theme by id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Theme params

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +object + + + + +

Theme identifier.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: THEME_ID };
+
+management.branding.getTheme(params, function (err, theme) {
+  if (err) {
+    // Handle error.
+  }
+
+   // Theme
+   console.log(theme);
+});
+ +
+ +
+ + +
+ + + +

getUniversalLoginTemplate(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the new universal login template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters (leave empty).

+ +
data + + +object + + + + + + + + + + +

Branding data (leave empty).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.branding.getUniversalLoginTemplate(data, function (err, template) {
+  if (err) {
+    // Handle error.
+  }
+
+// Branding
+   console.log(template);
+});
+ +
+ +
+ + +
+ + + +

setUniversalLoginTemplate(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Set the new universal login template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters (leavy empty).

+ +
data + + +object + + + + + + + + + + +

Branding data (object with template field).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.branding.setUniversalLoginTemplate(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

updateSettings(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the branding settings.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters (leavy empty).

+ +
data + + +object + + + + + + + + + + +

Updated branding data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.branding.updateSettings(params, data, function (err, branding) {
+  if (err) {
+    // Handle error.
+  }
+
+// Updated branding
+   console.log(branding);
+});
+ +
+ +
+ + +
+ + + +

updateTheme(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update a theme.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Theme parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +object + + + + +

Theme identifier.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated theme data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = THEME_OBJ;
+var params = { id: THEME_ID };
+
+management.branding.updateTheme(params, data, function (err, theme) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Theme updated.
+  console.log(theme);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/ClientGrantsManager.html b/docs/ClientGrantsManager.html new file mode 100644 index 000000000..9a4f11f32 --- /dev/null +++ b/docs/ClientGrantsManager.html @@ -0,0 +1,1569 @@ + + + + + + ClientGrantsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

ClientGrantsManager

+ + + + + + + +
+ +
+ +

+ ClientGrantsManager +

+ +

Auth0 Client Grants Manager.

+

See Client Grants

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new ClientGrantsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Client Grants endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 client grant.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The client data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.clientGrants.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Client grant created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 client grant.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Client grant ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.clientGrants.delete({ id: GRANT_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Grant deleted.
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Auth0 Client Grants.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Client Grants parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+
+management.clientGrants.getAll(params, function (err, grants) {
+  console.log(grants.length);
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an Auth0 client grant.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Client grant ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated client data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = {
+  client_id: CLIENT_ID,
+  audience: AUDIENCE,
+  scope: []
+};
+var params = { id: CLIENT_GRANT_ID };
+
+management.clientGrants.update(params, data, function (err, grant) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(grant.id);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/ClientsManager.html b/docs/ClientsManager.html new file mode 100644 index 000000000..7b62791e5 --- /dev/null +++ b/docs/ClientsManager.html @@ -0,0 +1,2187 @@ + + + + + + ClientsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

ClientsManager

+ + + + + + + +
+ +
+ +

+ ClientsManager +

+ +

Auth0 Clients Manager.

+

Clients represent +applications. +You can learn more about this in the +Applications section of the +documentation.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new ClientsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Clients endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

rotateSecretResource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Clients Rotate a client secret.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The client data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.clients.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Client created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
client_id + + +string + + + + +

Application client ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.clients.delete({ client_id: CLIENT_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Client deleted.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
client_id + + +string + + + + +

Application client ID.

+ +
fields + + +string + + + + +

Comma-separated list of fields to include or exclude (based on value provided for include_fields).

+ +
include_fields + + +string + + + + +

Whether specified fields are to be included (true) or excluded (false).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.clients.get({ client_id: CLIENT_ID }, function (err, client) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(client);
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Auth0 clients.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Clients parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.clients.getAll(params, function (err, clients) {
+  console.log(clients.length);
+});
+ +
+ +
+ + +
+ + + +

rotateClientSecret(params) → {Promise|undefined}

+ + + + + +
+

Rotate a client secret

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
params + + +object + + + + +

params object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
client_id + + +string + + + + +

Application client ID.

+ +
+ + +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.clients.rotateClientSecret({ client_id: CLIENT_ID }, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Client secret rotated.
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an Auth0 client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
client_id + + +string + + + + +

Application client ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated client data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'newClientName' };
+var params = { client_id: CLIENT_ID };
+
+management.clients.update(params, data, function (err, client) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(client.name);  // 'newClientName'
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/ConnectionsManager.html b/docs/ConnectionsManager.html new file mode 100644 index 000000000..466cdd0a5 --- /dev/null +++ b/docs/ConnectionsManager.html @@ -0,0 +1,2477 @@ + + + + + + ConnectionsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

ConnectionsManager

+ + + + + + + +
+ +
+ +

+ ConnectionsManager +

+ +

Represents the relationship between Auth0 and an Identity provider.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new ConnectionsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +Auth0 Connections.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

user :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

checkStatus(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Checks the status of an ad/ldap connection referenced by its ID.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Connection parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Connection.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +
var params = {id : 'CONNECTION_ID'}
+ +

+ This methods takes the connection ID and returns the status when online, or an error when offline. +

+ +
management.connections.checkStatus( {id : 'CONNECTION_ID'}, function (err, status) {
+  if (err) {
+    console.log('OFFLINE', err);
+  } else {
+    console.log('ONLINE', status);
+  }
+});
+ +
+ +
+ + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Connection data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.connections.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Connection created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Connection parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Connection ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.connections.delete({ id: CONNECTION_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Connection deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteUserByEmail(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a connection user by email.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Connection parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Connection ID.

+ +
email + + +string + + + + +

User Email.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.connections.deleteUserByEmail({ id: CONNECTION_ID, email:USER_EMAIL }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User deleted.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Connection parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Connection ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.connections.get({ id: CONNECTION_ID }, function (err, connection) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(connection);
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all connections.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Connections params.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.connections.getAll(params, function (err, connections) {
+  console.log(connections.length);
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Connection parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Connection ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated connection data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'newConnectionName' };
+var params = { id: CONNECTION_ID };
+
+management.connections.update(params, data, function (err, connection) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(connection.name);  // 'newConnectionName'
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/CustomDomainsManager.html b/docs/CustomDomainsManager.html new file mode 100644 index 000000000..6be1f75f1 --- /dev/null +++ b/docs/CustomDomainsManager.html @@ -0,0 +1,1664 @@ + + + + + + CustomDomainsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

CustomDomainsManager

+ + + + + + + +
+ +
+ +

+ CustomDomainsManager +

+ +

Auth0 Custom Domains Manager.

+

CustomDomains represent +custom domain names. +You can learn more about this in the +CustomDomains section of the +documentation.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new CustomDomainsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Custom Domains endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

vefifyResource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Custom Domains Verify endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 Custom Domain.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The custom domain data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.customDomains.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // CustomDomain created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a Custom Domain.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Custom Domain parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Custom Domain ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.customDomains.delete({ id: CUSTOM_DOMAIN_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // CustomDomain deleted.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a Custom Domain.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Custom Domain parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Custom Domain ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.customDomains.get({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(customDomain);
+});
+ +
+ +
+ + +
+ + + +

getAll() → {Promise|undefined}

+ + + + + +
+

Get all Auth0 CustomDomains.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.customDomains.getAll(function (err, customDomains) {
+  console.log(customDomains.length);
+});
+ +
+ +
+ + +
+ + + +

verify(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Verify a Custom Domain.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Custom Domain parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Custom Domain ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.customDomains.verify({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(customDomain);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/DatabaseAuthenticator.html b/docs/DatabaseAuthenticator.html new file mode 100644 index 000000000..2957ca0e5 --- /dev/null +++ b/docs/DatabaseAuthenticator.html @@ -0,0 +1,1695 @@ + + + + + + DatabaseAuthenticator - Documentation + + + + + + + + + + + + + + + + + +
+ +

DatabaseAuthenticator

+ + + + + + + +
+ +
+ +

+ DatabaseAuthenticator +

+ +

Abstracts the sign-in, sign-up and change-password processes for Database & +Active Directory authentication services.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new DatabaseAuthenticator(options, oauth)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

Authenticator options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The auth0 account URL.

+ +
clientId + + +string + + + + + + <optional>
+ + + + + +
+

Default client ID.

+ +
+ + +
oauth + + +OAuthAuthenticator + + + + +

OAuthAuthenticator instance.

+ +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

changePassword(userData, cbopt) → {Promise|undefined}

+ + + + + +
+

Change password using a database or active directory service.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +string + + + + +

User email address.

+ +
password + + +string + + + + +

New password.

+ +
connection + + +string + + + + +

Identity provider in use.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user email, the connection specified and the new password to + use, Auth0 will send a forgot password email. Once the user clicks on the + confirm password change link, the new password specified in this POST will + be set to this user. Find more information in the + var data = { + email: '{EMAIL}', + password: '{PASSWORD}', + connection: 'Username-Password-Authentication' +}; + +auth0.database.changePassword(data, function (err, message) { + if (err) { + // Handle error. + } + + console.log(message); +}); + +

+ +
+ + +
+ + + +

requestChangePasswordEmail(userData, cbopt) → {Promise|undefined}

+ + + + + +
+

Request a change password email using a database or active directory service.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +string + + + + +

User email address.

+ +
connection + + +string + + + + +

Identity provider in use.

+ +
client_id + + +string + + + + +

Client ID of the Application requesting the password change, to be included in the email template.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user email, the connection specified, Auth0 will send a change + password email. once the user clicks on the confirm password change link, + the new password specified in this POST will be set to this user. Find more + information in the var data = { + email: '{EMAIL}', + connection: 'Username-Password-Authentication', + client_id: 'OS1VzKTVjizL0VCc9Hx2ae2aTPXWy6BD' +}; + +auth0.database.requestChangePasswordEmail(data, function (err, message) { + if (err) { + // Handle error. + } + + console.log(message); +}); + +

+ +
+ + +
+ + + +

signIn(userData, cbopt) → {Promise|undefined}

+ + + + + +
+

Sign in using a database or active directory service.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
username + + +string + + + + +

Username.

+ +
password + + +string + + + + +

User password.

+ +
connection + + +string + + + + +

Identity provider in use.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user credentials and the connection specified, it will do the + authentication on the provider and return a JSON with the `access_token` + and `id_token`. Find more information about the structure of the data + object in the + API docs. +

+ +
var data = {
+  username: '{USERNAME}',
+  password: '{PASSWORD}',
+  connection: 'Username-Password-Authentication' // Optional field.
+};
+
+auth0.database.signIn(data, function (err, userData) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(userData);
+});
+ +
+ +
+ + +
+ + + +

signUp(userData, cbopt) → {Promise|undefined}

+ + + + + +
+

Sign up using a database or active directory service.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +string + + + + +

User email address.

+ +
password + + +string + + + + +

User password.

+ +
connection + + +string + + + + +

Identity provider in use.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user credentials, the connection specified and (optionally) the + client ID, it will create a new user. Find more information in the + + API Docs. +

+ +
var data = {
+  email: '{EMAIL}',
+  password: '{PASSWORD}',
+  connection: 'Username-Password-Authentication' // Optional field.
+};
+
+auth0.database.signUp(data, function (err, userData) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(userData);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/DeviceCredentialsManager.html b/docs/DeviceCredentialsManager.html new file mode 100644 index 000000000..f8c35eb5c --- /dev/null +++ b/docs/DeviceCredentialsManager.html @@ -0,0 +1,1148 @@ + + + + + + DeviceCredentialsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

DeviceCredentialsManager

+ + + + + + + +
+ +
+ +

+ DeviceCredentialsManager +

+ +

Manages Auth0 Device Credentials.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new DeviceCredentialsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 DeviceCredentialsManagers endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

createPublicKey(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 credential.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The device credential data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deviceCredentials.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Credential created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 device credential.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Credential parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Device credential ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: CREDENTIAL_ID };
+
+management.deviceCredentials.delete(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Credential deleted.
+});
+ +
+ +
+ + +
+ + + +

getAll(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Auth0 credentials.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Credential parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {user_id: "USER_ID"};
+
+management.deviceCredentials.getAll(params, function (err, credentials) {
+  console.log(credentials.length);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/EmailProviderManager.html b/docs/EmailProviderManager.html new file mode 100644 index 000000000..aec193adc --- /dev/null +++ b/docs/EmailProviderManager.html @@ -0,0 +1,1413 @@ + + + + + + EmailProviderManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

EmailProviderManager

+ + + + + + + +
+ +
+ +

+ EmailProviderManager +

+ +

Auth0 Email Provider.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new EmailProviderManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Clients endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

configure(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Configure the email provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The email provider data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.emailProvider.configure(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Email provider configured.
+});
+ +
+ +
+ + +
+ + + +

delete(cbopt) → {Promise|undefined}

+ + + + + +
+

Delete email provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.emailProvider.delete(function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Email provider configured.
+});
+ +
+ +
+ + +
+ + + +

get(cbopt, paramsopt) → {Promise|undefined}

+ + + + + +
+

Get the email provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
params + + +object + + + + + + <optional>
+ + + + + +
+

Clients parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
fields + + +number + + + + + + <optional>
+ + + + + +
+

A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields.

+ +
include_fields + + +number + + + + + + <optional>
+ + + + + +
+

true if the fields specified are to be excluded from the result, false otherwise (defaults to true)

+ +
+ + +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.emailProvider.get(function (err, provider) {
+  console.log(provider);
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the email provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Email provider parameters.

+ +
data + + +object + + + + + + + + + + +

Updated email provider data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.emailProvider.update(params, data, function (err, provider) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Updated email provider.
+  console.log(provider);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/EmailTemplatesManager.html b/docs/EmailTemplatesManager.html new file mode 100644 index 000000000..9f8ac4397 --- /dev/null +++ b/docs/EmailTemplatesManager.html @@ -0,0 +1,1237 @@ + + + + + + EmailTemplatesManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

EmailTemplatesManager

+ + + + + + + +
+ +
+ +

+ EmailTemplatesManager +

+ +

This class provides a simple abstraction for performing CRUD operations +on Auth0's Email Templates. https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new EmailTemplatesManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +Auth0's Email Templates.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new Email Template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Email Template data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.emailTemplates.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Email Template created.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 Email Template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Email Template parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Template Name

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.emailTemplates.get({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(emailTemplate);
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing Email Template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Email Template parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Template Name

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated Email Template data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { from: 'new@email.com' };
+var params = { name: EMAIL_TEMPLATE_NAME };
+
+management.emailTemplates.update(params, data, function (err, emailTemplate) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(emailTemplate.from);  // 'new@email.com'
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/GrantsManager.html b/docs/GrantsManager.html new file mode 100644 index 000000000..edf13eca7 --- /dev/null +++ b/docs/GrantsManager.html @@ -0,0 +1,1148 @@ + + + + + + GrantsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

GrantsManager

+ + + + + + + +
+ +
+ +

+ GrantsManager +

+ +

Auth0 Grants Manager.

+

See Grants

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new GrantsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Grants endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 grant.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Grant parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Grant ID.

+ +
user_id + + +string + + + + +

The user_id of the grants to delete.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+   id: 'GRANT_ID',
+   user_id: 'USER_ID'
+};
+
+management.deleteGrant(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Grant deleted.
+});
+ +
+ +
+ + +
+ + + +

getAll(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Auth0 Grants.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Grants parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
per_page + + +number + + + + +

Number of results per page.

+ +
page + + +number + + + + +

Page number, zero indexed.

+ +
include_totals + + +boolean + + + + +

true if a query summary must be included in the result, false otherwise. Default false;

+ +
user_id + + +string + + + + +

The user_id of the grants to retrieve.

+ +
client_id + + +string + + + + +

The client_id of the grants to retrieve.

+ +
audience + + +string + + + + +

The audience of the grants to retrieve.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  per_page: 10,
+  page: 0,
+  include_totals: true,
+  user_id: 'USER_ID',
+  client_id: 'CLIENT_ID',
+  audience: 'AUDIENCE'
+};
+
+management.getGrants(params, function (err, grants) {
+  console.log(grants.length);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/GuardianManager.html b/docs/GuardianManager.html new file mode 100644 index 000000000..63da631c7 --- /dev/null +++ b/docs/GuardianManager.html @@ -0,0 +1,4928 @@ + + + + + + GuardianManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

GuardianManager

+ + + + + + + +
+ +
+ +

+ GuardianManager +

+ +

Abstracts interaction with the Guardian endpoint.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new GuardianManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

enrollments :external:RestClient

+ + + + +
+

Provides an abstraction layer for retrieving Guardian enrollments.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

factors :external:RestClient

+ + + + +
+

Provides an abstraction layer for retrieving Guardian factors.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

factorSettings :external:RestClient

+ + + + +
+

Provides an abstraction layer for configuring Factor settings

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

factorsPhoneMessageTypes :external:RestClient

+ + + + +
+

Provides an abstraction layer for retrieving Guardian phone factor message types.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

factorsPhoneSelectedProvider :external:RestClient

+ + + + +
+

Provides an abstraction layer for retrieving Guardian phone factor selected provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

factorsProviders :external:RestClient

+ + + + +
+

Provides an abstraction layer for retrieving Guardian factor providers.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

factorsTemplates :external:RestClient

+ + + + +
+

Provides an abstraction layer for retrieving Guardian factor templates.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

policies :external:RestClient

+ + + + +
+

Provides an abstraction layer for retrieving Guardian policies.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

tickets :external:RestClient

+ + + + +
+

Provides an abstraction layer for retrieving Guardian tickets.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

createEnrollmentTicket(cbopt) → {Promise|undefined}

+ + + + + +
+

Create a Guardian enrollment ticket.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.createEnrollmentTicket(function (err, ticket) {
+  console.log(ticket);
+});
+ +
+ +
+ + +
+ + + +

deleteGuardianEnrollment(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a Guardian enrollment.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollments) {
+  console.log(enrollments);
+});
+ +
+ +
+ + +
+ + + +

getFactorProvider(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Guardian factor provider configuration

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor provider parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) {
+  console.log(provider);
+});
+ +
+ +
+ + +
+ + + +

getFactors(cbopt) → {Promise|undefined}

+ + + + + +
+

Get a list of factors and statuses.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.getFactors(function (err, factors) {
+  console.log(factors.length);
+});
+ +
+ +
+ + +
+ + + +

getFactorSettings(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Guardian factor configuration

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.getFactorSettings({ name: 'webauthn-roaming' }, function (err, settings) {
+  console.log(settings);
+});
+ +
+ +
+ + +
+ + + +

getFactorTemplates(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Guardian enrollment and verification factor templates

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.getFactorTemplates({ name: 'sms' }, function (err, templates) {
+  console.log(templates);
+});
+ +
+ +
+ + +
+ + + +

getGuardianEnrollment(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a single Guardian enrollment.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) {
+  console.log(enrollment);
+});
+ +
+ +
+ + +
+ + + +

getPhoneFactorMessageTypes(cbopt) → {Promise|undefined}

+ + + + + +
+

Get the Guardian phone factor's message types

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.getPhoneFactorMessageTypes(function (err, messageTypes) {
+  console.log(messageTypes);
+});
+ +
+ +
+ + +
+ + + +

getPhoneFactorSelectedProvider(cbopt) → {Promise|undefined}

+ + + + + +
+

Get the Guardian phone factor's selected provider

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.getPhoneFactorSelectedProvider(function (err, selectedProvider) {
+  console.log(selectedProvider);
+});
+ +
+ +
+ + +
+ + + +

getPolicies(cbopt) → {Promise|undefined}

+ + + + + +
+

Get enabled Guardian policies

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.getPolicies(function (err, policies) {
+  console.log(policies);
+});
+ +
+ +
+ + +
+ + + +

updateFactor(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update Guardian Factor

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
data + + +object + + + + + + + + + + +

Updated factor data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.updateFactor({ name: 'sms' }, {
+  enabled: true
+}, function (err, factor) {
+  console.log(factor);
+});
+ +
+ +
+ + +
+ + + +

updateFactorProvider(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update Guardian's factor provider

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor provider parameters.

+ +
data + + +object + + + + + + + + + + +

Updated Factor provider data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.updateFactorProvider({ name: 'sms', provider: 'twilio' }, {
+  messaging_service_sid: 'XXXXXXXXXXXXXX',
+  auth_token: 'XXXXXXXXXXXXXX',
+  sid: 'XXXXXXXXXXXXXX'
+}, function (err, provider) {
+  console.log(provider);
+});
+ +
+ +
+ + +
+ + + +

updateFactorSettings(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Update Guardian factor configuration

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.updateFactorSettings(
+ { name: 'webauthn-roaming' },
+ { userVerification: 'discouraged', overrideRelyingParty: false },
+ function (err, settings) {
+  console.log(settings);
+});
+ +
+ +
+ + +
+ + + +

updateFactorTemplates(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update Guardian enrollment and verification factor templates

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
data + + +object + + + + + + + + + + +

Updated factor templates data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.updateFactorProvider({ name: 'sms' }, {
+  enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.",
+  verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}"
+}, function (err, templates) {
+  console.log(templates);
+});
+ +
+ +
+ + +
+ + + +

updatePhoneFactorMessageTypes(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the Guardian phone factor's message types

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Parameters.

+ +
data + + +object + + + + + + + + + + +

Updated selected provider data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
message_types + + +Array.<string> + + + + +

Message types (only "sms" and "voice" are supported).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.updatePhoneFactorMessageTypes({}, {
+  message_types: ['sms', 'voice']
+}, function (err, factor) {
+  console.log(factor);
+});
+ +
+ +
+ + +
+ + + +

updatePhoneFactorSelectedProvider(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the Guardian phone factor's selected provider

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Parameters.

+ +
data + + +object + + + + + + + + + + +

Updated selected provider data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
provider + + +string + + + + +

Name of the selected provider

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.updatePhoneFactorSelectedProvider({}, {
+  provider: 'twilio'
+}, function (err, factor) {
+  console.log(factor);
+});
+ +
+ +
+ + +
+ + + +

updatePolicies(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update enabled Guardian policies

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Parameters.

+ +
data + + +Array.<string> + + + + + + + + + + +

Policies to enable. Empty array disables all policies.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.guardian.updatePolicies({}, [
+  'all-applications'
+], function (err, policies) {
+  console.log(policies);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/HooksManager.html b/docs/HooksManager.html new file mode 100644 index 000000000..97975ee93 --- /dev/null +++ b/docs/HooksManager.html @@ -0,0 +1,3032 @@ + + + + + + HooksManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

HooksManager

+ + + + + + + +
+ +
+ +

+ HooksManager +

+ +

The hooks manager class provides a simple abstraction for performing CRUD operations +on Auth0 HooksManagers.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new HooksManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +Auth0 HooksManagers.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

addSecrets(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Add secrets in a hook

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Hook.

+ +
+ + +
data + + +object + + + + + + + + + + +

object containing secrets as key/value pairs

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'HOOK_ID'};
+var data   = { "DB_USER" :  "jdoe", "DB_PASS": "password123!"};
+
+management.hooks.addSecrets(params, data, function (err, secrets) {
+  if (err) {
+    // Handle error.
+  }
+
+  // secrets added.
+});
+ +
+ +
+ + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Hook data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.hooks.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Hook created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.hooks.delete({ id: HOOK_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Hook deleted.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.hooks.get({ id: HOOK_ID }, function (err, hook) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(hook);
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all hooks.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Hooks parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.hooks.getAll(params, function (err, hooks) {
+  console.log(hooks.length);
+});
+ +
+ +
+ + +
+ + + +

getSecrets(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Hook secrets

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Hook.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes a first argument as the hookId and returns the secrets for the hook. The secret values will be hidden. +

+ +
var params = {id : 'HOOK_ID'}
+
+management.hooks.getSecrets( {id : 'HOOK_ID'}, function (err, secrets) {
+  console.log(secrets);
+});
+ +
+ +
+ + +
+ + + +

removeSecrets(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Remove secrets from a hook

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Hook.

+ +
+ + +
data + + +object + + + + + + + + + + +

Array of secret names

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'HOOK_ID'};
+var data =["DB_PASS"];
+
+management.hooks.removeSecrets(params, data, function (err, hook) {
+  if (err) {
+    // Handle error.
+  }
+
+  // secrets added.
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated hook data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'New name' };
+var params = { id: HOOK_ID };
+
+// Using auth0 instance.
+management.updateHook(params, data, function (err, hook) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(hook.name);  // 'New name'
+});
+
+// Using the hooks manager directly.
+management.hooks.update(params, data, function (err, hook) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(hook.name);  // 'New name'
+});
+ +
+ +
+ + +
+ + + +

updateSecrets(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update secrets in a hook

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Hook.

+ +
+ + +
data + + +object + + + + + + + + + + +

object containing secrets as key/value pairs

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'HOOK_ID'};
+var data   = { "DB_USER" :  "jdoe", "DB_PASS": "password123!"};
+
+management.hooks.updateSecrets(params, data, function (err, secrets) {
+  if (err) {
+    // Handle error.
+  }
+
+  // secrets updated.
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/JobsManager.html b/docs/JobsManager.html new file mode 100644 index 000000000..21ab38ddd --- /dev/null +++ b/docs/JobsManager.html @@ -0,0 +1,2879 @@ + + + + + + JobsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

JobsManager

+ + + + + + + +
+ +
+ +

+ JobsManager +

+ +

Abstract the creation as well as the retrieval of async jobs.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new JobsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

jobErrors :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Errors endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

jobs :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Jobs endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

usersExports :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Create job to export users endpoint

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

errors(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Given a job ID, retrieve the failed/errored items

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Job parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Job ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  id: '{JOB_ID}'
+};
+
+management.jobs.errors(params, function (err, job) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Retrieved job.
+  console.log(job);
+});
+ +
+ +
+ + +
+ + + +

exportUsers(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Export all users to a file using a long running job.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Users export data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
connection_id + + +string + + + + + + <optional>
+ + + + + +
+

The connection id of the connection from which users will be exported

+ +
format + + +string + + + + + + <optional>
+ + + + + +
+

The format of the file. Valid values are: "json" and "csv".

+ +
limit + + +number + + + + + + <optional>
+ + + + + +
+

Limit the number of records.

+ +
fields + + +Array.<object> + + + + + + <optional>
+ + + + + +
+

A list of fields to be included in the CSV. If omitted, a set of predefined fields will be exported.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = {
+  connection_id: 'con_0000000000000001',
+  format: 'csv',
+  limit: 5,
+  fields: [
+    {
+      "name": "user_id"
+    },
+    {
+      "name": "name"
+    },
+    {
+      "name": "email"
+    },
+    {
+      "name": "identities[0].connection",
+      "export_as": "provider"
+    },
+    {
+      "name": "user_metadata.some_field"
+    }
+  ]
+}
+
+management.jobs.exportUsers(data, function (err, results) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Retrieved job.
+  console.log(results);
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a job by its ID.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Job parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Job ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  id: '{JOB_ID}'
+};
+
+management.jobs.get(params, function (err, job) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Retrieved job.
+  console.log(job);
+});
+ +
+ +
+ + +
+ + + +

importUsers(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Given a path to a file and a connection id, create a new job that imports the +users contained in the file or JSON string and associate them with the given +connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + +
Deprecated:
  • since version 2.26. It will be deleted in version 3.0.
+ + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Users import data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
connection_id + + +string + + + + + + + + + + +

connection_id of the connection to which users will be imported.

+ +
users + + +string + + + + + + <optional>
+ + + + + +
+

Path to the users data file. Either users or users_json is mandatory.

+ +
users_json + + +string + + + + + + <optional>
+ + + + + +
+

JSON data for the users.

+ +
upsert + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to update users if they already exist (true) or to ignore them (false).

+ +
send_completion_email + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to send a completion email to all tenant owners when the job is finished (true) or not (false).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  connection_id: '{CONNECTION_ID}',
+  users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}'
+};
+
+management.jobs.importUsers(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

importUsersJob(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Given a path to a file and a connection id, create a new job that imports the +users contained in the file or JSON string and associate them with the given +connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Users import data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
connection_id + + +string + + + + + + + + + + +

connection_id of the connection to which users will be imported.

+ +
users + + +string + + + + + + <optional>
+ + + + + +
+

Path to the users data file. Either users or users_json is mandatory.

+ +
users_json + + +string + + + + + + <optional>
+ + + + + +
+

JSON data for the users.

+ +
upsert + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to update users if they already exist (true) or to ignore them (false).

+ +
send_completion_email + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to send a completion email to all tenant owners when the job is finished (true) or not (false).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  connection_id: '{CONNECTION_ID}',
+  users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}'
+};
+
+management.jobs.importUsers(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

verifyEmail(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Send a verification email to a user.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

User data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
user_id + + +string + + + + + + + + + + +

ID of the user to be verified.

+ +
organization_id + + +string + + + + + + <optional>
+ + + + + +
+

Organization ID

+ +
client_id + + +string + + + + + + <optional>
+ + + + + +
+

client_id of the client (application). If no value provided, the global Client ID will be used.

+ +
identity + + +object + + + + + + <optional>
+ + + + + +
+

Used to verify secondary, federated, and passwordless-email identities.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
user_id + + +string + + + + +

user_id of the identity.

+ +
provider + + +string + + + + +

provider of the identity.

+ +
+ + +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+	user_id: '{USER_ID}'
+};
+
+management.jobs.verifyEmail(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/LogStreamsManager.html b/docs/LogStreamsManager.html new file mode 100644 index 000000000..097fb708e --- /dev/null +++ b/docs/LogStreamsManager.html @@ -0,0 +1,1696 @@ + + + + + + LogStreamsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

LogStreamsManager

+ + + + + + + +
+ +
+ +

+ LogStreamsManager +

+ +

The logStreams class provides a simple abstraction for performing CRUD operations +on Auth0 Log Streams.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new LogStreamsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +Auth0 Log Streams.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 Log Stream.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Log Stream data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.logStreams.create(data, function (err, log) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(log);
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 Log Streams.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Log Stream parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Log Stream ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.logStreams.delete({ id: LOG_STREAM_ID }, function (err, log) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(log);
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 Log Streams.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Log Stream parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Log Stream ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.logStreams.get({ id: LOG_STREAM_ID }, function (err, logStream) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(logStream);
+});
+ +
+ +
+ + +
+ + + +

getAll(cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Log Streams.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.logStreams.getAll(function (err, logStreams) {
+  console.log(logStreams.length);
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an Auth0 Log Streams.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Log Stream parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Log Stream ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated Log Stream data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'New name' };
+var params = { id: LOG_STREAM_ID };
+
+// Using auth0 instance.
+management.updateLogStream(params, data, function (err, logStream) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(logStream.name);  // 'New name'
+});
+
+// Using the logStreams manager directly.
+management.logStreams.update(params, data, function (err, logStream) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(logStream.name);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/LogsManager.html b/docs/LogsManager.html new file mode 100644 index 000000000..da955c179 --- /dev/null +++ b/docs/LogsManager.html @@ -0,0 +1,1291 @@ + + + + + + LogsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

LogsManager

+ + + + + + + +
+ +
+ +

+ LogsManager +

+ +

Represents the relationship between Auth0 and an Identity provider.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new LogsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +Auth0 Logs.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 log.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Log parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Log ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.logs.get({ id: EVENT_ID }, function (err, log) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(log);
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all logs.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Logs params.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
q + + +string + + + + + + <optional>
+ + + + + +
+

Search Criteria using Query String Syntax

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number. Zero based

+ +
per_page + + +number + + + + + + <optional>
+ + + + + +
+

The amount of entries per page

+ +
sort + + +string + + + + + + <optional>
+ + + + + +
+

The field to use for sorting.

+ +
fields + + +string + + + + + + <optional>
+ + + + + +
+

A comma separated list of fields to include or exclude

+ +
include_fields + + +boolean + + + + + + <optional>
+ + + + + +
+

true if the fields specified are to be included in the result, false otherwise.

+ +
include_totals + + +boolean + + + + + + <optional>
+ + + + + +
+

true if a query summary must be included in the result, false otherwise. Default false

+ +
from + + +string + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, log event Id from which to start selection from.

+ +
take + + +number + + + + + + <optional>
+ + + + + +
+

When using the from parameter, the number of entries to retrieve. Default 50, max 100.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings and the search query. If pagination options are + not present, the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 2
+};
+
+management.logs.getAll(params, function (err, logs) {
+  console.log(logs.length);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/ManagementClient.html b/docs/ManagementClient.html new file mode 100644 index 000000000..e3003194a --- /dev/null +++ b/docs/ManagementClient.html @@ -0,0 +1,41643 @@ + + + + + + ManagementClient - Documentation + + + + + + + + + + + + + + + + + +
+ +

ManagementClient

+ + + + + + + +
+ +
+ +

+ ManagementClient +

+ +

Management API SDK.

+

The Auth0 Management API is meant to be used by back-end servers or trusted +parties performing administrative tasks. Generally speaking, anything that +can be done through the Auth0 dashboard (and more) can also be done through +this API.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new ManagementClient(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

Options for the ManagementClient SDK. +If a token is provided only the domain is required, other parameters are ignored. +If no token is provided domain, clientId, clientSecret and scopes are required

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDefaultDescription
domain + + +string + + + + + + + + + + + + +

ManagementClient server domain.

+ +
token + + +string + + + + + + <optional>
+ + + + + +
+ + +

API access token.

+ +
clientId + + +string + + + + + + <optional>
+ + + + + +
+ + +

Management API Non Interactive Client Id.

+ +
clientSecret + + +string + + + + + + <optional>
+ + + + + +
+ + +

Management API Non Interactive Client Secret.

+ +
audience + + +string + + + + + + <optional>
+ + + + + +
+ + +

Management API Audience. By default is your domain's, e.g. the domain is tenant.auth0.com and the audience is http://tenant.auth0.com/api/v2/

+ +
scope + + +string + + + + + + <optional>
+ + + + + +
+ + +

Management API Scopes.

+ +
tokenProvider.enableCache + + +boolean + + + + + + <optional>
+ + + + + +
+ + true + + +

Enabled or Disable Cache.

+ +
tokenProvider.cacheTTLInSeconds + + +number + + + + + + <optional>
+ + + + + +
+ + +

By default the expires_in value will be used to determine the cached time of the token, this can be overridden.

+ +
retry.enabled + + +boolean + + + + + + <optional>
+ + + + + +
+ + true + + +

Enabled or Disable Retry Policy functionality.

+ +
retry.maxRetries + + +number + + + + + + <optional>
+ + + + + +
+ + 10 + + +

Retry failed requests X times.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+ + +

Additional headers that will be added to the outgoing requests.

+ +
proxy + + +string + + + + + + <optional>
+ + + + + +
+ + +

Add the superagent-proxy dependency and specify a proxy url eg 'https://myproxy.com:1234'

+ +
includeResponseHeaders + + +boolean + + + + + + <optional>
+ + + + + +
+ + +

Include the response headers in the payload in the format { data, headers }.

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+
Examples
+ +

+ Initialize your client class with an API v2 token (you can generate one + here) and a domain. +

+ +
var ManagementClient = require('auth0').ManagementClient;
+var auth0 = new ManagementClient({
+  domain: '{YOUR_ACCOUNT}.auth0.com',
+  token: '{YOUR_API_V2_TOKEN}'
+});
+ +

+ Initialize your client class, by using a Non Interactive Client to fetch an access_token + via the Client Credentials Grant. +

+ +
var ManagementClient = require('auth0').ManagementClient;
+var auth0 = new ManagementClient({
+  domain: '{YOUR_ACCOUNT}.auth0.com',
+  clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',
+  clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}',
+  scope: "read:users write:users",
+  audience: 'https://{YOUR_TENANT_NAME}.auth0.com/api/v2/',
+  tokenProvider: {
+   enableCache: true,
+   cacheTTLInSeconds: 10
+ }
+});
+ +
+ +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

actions :ActionsManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +actions endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

attackProtection :AttackProtectionManager

+ + + + +
+

Attack Protection Manager

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

blacklistedTokens :BlacklistedTokensManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +blacklisted tokens endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

branding :BrandingManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +branding endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

clientGrants :ClientGrantsManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the client grants +endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

clients :ClientsManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +clients endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

connections :ConnectionsManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +connections endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

customDomains :CustomDomainsManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +custom domains endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

deviceCredentials :DeviceCredentialsManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +device credentials endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

emailProvider :EmailProviderManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +email provider endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

emailTemplates :EmailTemplatesManager

+ + + + +
+

Simple abstraction for performing CRUD operations on +Auth0's Email Templates

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

grants :GrantsManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the grants +endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

guardian :GuardianManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +guardian endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

hooks :HooksManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +hooks endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

jobs :JobsManager

+ + + + +
+

Jobs manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

logs :LogsManager

+ + + + +
+

Logs manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

logStreams :LogStreamsManager

+ + + + +
+

Log Streams manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

migrations :MigrationsManager

+ + + + +
+

ManagementClient migrations manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

organizations :OrganizationsManager

+ + + + +
+

Organizations Manager

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

prompts :PromptsManager

+ + + + +
+

Prompts Manager

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

resourceServers :ResourceServersManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +resource servers endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

roles :RolesManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +roles endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

rules :RulesManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +rules endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

rulesConfigs :RulesConfigsManager

+ + + + +
+

RulesConfigs manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

stats :StatsManager

+ + + + +
+

ManagementClient account statistics manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

tenant :TenantManager

+ + + + +
+

ManagementClient tenant settings manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

tickets :TicketsManager

+ + + + +
+

Tickets manager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

userBlocks :UserBlocksManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +user-blocks endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

users :UsersManager

+ + + + +
+

Simple abstraction for performing CRUD operations on the +users endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

addHookSecrets(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Add hook screts.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Secrets key/value pairs

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: 'HOOK_ID' }
+var data = { DB_PASSWORD: 'password1', API_TOKEN: 'secret' }
+management.addHookScrets(params, data, function (err, secrets) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Hook secrets created.
+});
+ +
+ +
+ + +
+ + + +

addPermissionsInRole(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Add permissions in a role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params.id + + +string + + + + + + + + + + +

ID of the Role.

+ +
data + + +object + + + + + + + + + + +

permissions data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permissions + + +string + + + + +

Array of permissions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permission_name + + +string + + + + +

Name of a permission

+ +
resource_server_identifier + + +string + + + + +

Identifier for a resource

+ +
+ + +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id :'ROLE_ID'};
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.addPermissionsInRole(params, data, function (err, permissions) {
+  console.log(permissions);
+});
+ +
+ +
+ + +
+ + + +

assignPermissionsToUser(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Assign permissions to a user

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

params object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

user_id

+ +
+ + +
data + + +string + + + + + + + + + + +

data object containing list of permissions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permissions + + +string + + + + +

Array of permission IDs

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var parms =  { id : 'USER_ID'};
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.assignPermissionsToUser(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User assigned permissions.
+});
+ +
+ +
+ + +
+ + + +

assignRolestoUser(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Assign roles to a user

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

params object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

user_id

+ +
+ + +
data + + +object + + + + + + + + + + +

data object containing list of role IDs

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
roles + + +string + + + + +

Array of role IDs

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var parms =  { id : 'USER_ID'};
+var data = { "roles" :["role1"]};
+
+management.assignRolestoUser(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User assigned roles.
+});
+ +
+ +
+ + +
+ + + +

assignUsersToRole(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Assign users to a role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params.id + + +string + + + + + + + + + + +

ID of the Role.

+ +
data + + +object + + + + + + + + + + +

permissions data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permissions + + +string + + + + +

Array of permissions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permission_name + + +string + + + + +

Name of a permission

+ +
resource_server_identifier + + +string + + + + +

Identifier for a resource

+ +
+ + +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ROLE_ID'};
+var data = { "users" : ["userId1","userId2"]};
+
+management.roles.assignUsers(params, data, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // permissions added.
+});
+ +
+ +
+ + +
+ + + +

blacklistToken(token, cbopt) → {Promise|undefined}

+ + + + + +
+

Blacklist a new token.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
token + + +object + + + + + + + + + + +

Token data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
aud + + +string + + + + +

Audience (your app client ID).

+ +
jti + + +string + + + + +

The JWT ID claim.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var token = {
+ aud: 'aud',
+ jti: 'jti'
+};
+
+management.blacklistToken(token, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Token blacklisted.
+});
+ +
+ +
+ + +
+ + + +

configureEmailProvider(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Configure the email provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The email provider data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.configureEmailProvider(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Email provider configured.
+});
+ +
+ +
+ + +
+ + + +

createClient(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The client data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createClient(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Client created.
+});
+ +
+ +
+ + +
+ + + +

createClientGrant(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 client grant.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The client data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.clientGrants.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Client grant created.
+});
+ +
+ +
+ + +
+ + + +

createConnection(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Connection data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createConnection(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Connection created.
+});
+ +
+ +
+ + +
+ + + +

createCustomDomain(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 Custom Domain.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The custom domain data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createCustomDomain(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // CustomDomain created.
+});
+ +
+ +
+ + +
+ + + +

createDevicePublicKey(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an Auth0 credential.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The device credential data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createConnection(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Credential created.
+});
+ +
+ +
+ + +
+ + + +

createEmailTemplate(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new Email Template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Email Template data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createEmailTemplate(data, function (err) {
+  if (err) {
+    // Handle error.
+  // Email Template created.
+});
+ +
+ +
+ + +
+ + + +

createEmailVerificationTicket(cbopt) → {Promise}

+ + + + + +
+

Create an email verification ticket.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = {
+  user_id: '{USER_ID}',
+  result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
+};
+
+auth0.createEmailVerificationTicket(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

createGuardianEnrollmentTicket(cbopt) → {Promise|undefined}

+ + + + + +
+

Create a Guardian enrollment ticket.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createGuardianEnrollmentTicket(function (err, ticket) {
+  console.log(ticket);
+});
+ +
+ +
+ + +
+ + + +

createHook(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Hook data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createHook(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Hook created.
+});
+ +
+ +
+ + +
+ + + +

createLogStream(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new Log Stream.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Log Stream data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createLogStream(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Log Stream created.
+});
+ +
+ +
+ + +
+ + + +

createPasswordChangeTicket(cbopt) → {Promise}

+ + + + + +
+

Create a new password change ticket.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  result_url: '{REDIRECT_URL}',  // Redirect after using the ticket.
+  user_id: '{USER_ID}'
+};
+
+// or
+
+var params = {
+  result_url: '{REDIRECT_URL}',  // Redirect after using the ticket.
+  email: '{USER_EMAIL}',
+  connection_id: '{CONNECTION}' // eg. con_00000000001
+};
+
+auth0.createPasswordChangeTicket(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

createResourceServer(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new resource server.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Resource Server data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createResourceServer(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Resource Server created.
+});
+ +
+ +
+ + +
+ + + +

createRole(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new role.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Role data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
data = {"name": "test1","description": "123"}
+management.createRole(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Role created.
+});
+ +
+ +
+ + +
+ + + +

createRule(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new rule.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Rule data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createRule(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Rule created.
+});
+ +
+ +
+ + +
+ + + +

createUser(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new user.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

User data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.createUser(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User created.
+});
+ +
+ +
+ + +
+ + + +

deleteAllUsers(cbopt) → {Promise|undefined}

+ + + + + +
+

Delete all users.

+
+ + + + + +
+ + + + + + + + + + + + + + + + +
Deprecated:
  • This method will be removed in the next major release.
+ + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteAllUsers(function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Users deleted
+});
+ +
+ +
+ + +
+ + + +

deleteBrandingUniversalLoginTemplate(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete the new universal login template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters (leave empty).

+ +
data + + +object + + + + + + + + + + +

Branding data (leave empty).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteBrandingUniversalLoginTemplate(template, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

deleteClient(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
client_id + + +string + + + + +

Application client ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteClient({ client_id: CLIENT_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Client deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteClientGrant(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 client grant.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Client grant ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.clientGrants.delete({ id: GRANT_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Grant deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteConnection(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Connection parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Connection ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteConnection({ id: CONNECTION_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Connection deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteCustomDomain(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a Custom Domain.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Custom Domain parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Custom Domain ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // CustomDomain deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteDeviceCredential(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 device credential.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Credential parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Device credential ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: CREDENTIAL_ID };
+
+management.deleteDeviceCredential(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Credential deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteEmailProvider(cbopt) → {Promise|undefined}

+ + + + + +
+

Delete email provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteEmailProvider(function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Email provider deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteGrant(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an Auth0 grant.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Grant parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Grant ID.

+ +
user_id + + +string + + + + +

The user_id of the grants to delete.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+   id: GRANT_ID,
+   user_id: USER_ID
+};
+
+management.deleteGrant(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Grant deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteGuardianEnrollment(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a user's Guardian enrollment.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The Guardian enrollment data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The Guardian enrollment id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Email provider deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteHook(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
auth0.deleteHook({ id: HOOK_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Hook deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteLogStream(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing Log Stream.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Log Stream parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Log Stream ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteLogStream({ id: LOG_STREAM_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Log Stream deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteResourceServer(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing resource server.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Resource Server parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Resource Server ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteResourceServer({ id: RESOURCE_SERVER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Resource Server deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteRole(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing role.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Role parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Role ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteRole({ id: ROLE_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Role deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteRule(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing rule.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Rule ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
auth0.deleteRule({ id: RULE_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Rule deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteRulesConfig(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete rules config.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule Configs parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +string + + + + +

Rule Configs key.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteRulesConfig({ key: RULE_CONFIG_KEY }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Rules Config deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteUser(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a user by its id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.deleteUser({ id: USER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteUserMultifactor(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a multifactor provider for a user.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
provider + + +string + + + + +

Multifactor provider.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
+
+management.deleteUserMultifactor(params, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Users accounts unlinked.
+});
+ +
+ +
+ + +
+ + + +

deleteUserMultifcator(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete a multifactor provider for a user.

+
+ + + + + +
+ + + + + + + + + + + + + + + + +
Deprecated:
  • The function name has a typo. +We're shipping this so it doesn't break compatibility. +Use deleteUserMultifactor instead.
+ + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
provider + + +string + + + + +

Multifactor provider.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
+
+management.deleteUserMultifcator(params, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Users accounts unlinked.
+});
+ +
+ +
+ + +
+ + + +

exportUsers(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Export all users to a file using a long running job.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Users export data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
connection_id + + +string + + + + + + <optional>
+ + + + + +
+

The connection id of the connection from which users will be exported

+ +
format + + +string + + + + + + <optional>
+ + + + + +
+

The format of the file. Valid values are: "json" and "csv".

+ +
limit + + +number + + + + + + <optional>
+ + + + + +
+

Limit the number of records.

+ +
fields + + +Array.<object> + + + + + + <optional>
+ + + + + +
+

A list of fields to be included in the CSV. If omitted, a set of predefined fields will be exported.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = {
+  connection_id: 'con_0000000000000001',
+  format: 'csv',
+  limit: 5,
+  fields: [
+    {
+      "name": "user_id"
+    },
+    {
+      "name": "name"
+    },
+    {
+      "name": "email"
+    },
+    {
+      "name": "identities[0].connection",
+      "export_as": "provider"
+    },
+    {
+      "name": "user_metadata.some_field"
+    }
+  ]
+}
+
+management.exportUsers(data, function (err, results) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Retrieved job.
+  console.log(results);
+});
+ +
+ +
+ + +
+ + + +

getAccessToken() → {Promise}

+ + + + + +
+

Returns the access_token.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise + + +
+
+ + +
+

Promise returning an access_token.

+
+ + +
+ + + +
+ + +
+ + + +

getActiveUsersCount(cbopt) → {Promise|undefined}

+ + + + + +
+

Get a the active users count.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getActiveUsersCount(function (err, usersCount) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(usersCount);
+});
+ +
+ +
+ + +
+ + + +

getBlacklistedTokens(cbopt) → {Promise|undefined}

+ + + + + +
+

Get all blacklisted tokens.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getBlacklistedTokens(function (err, tokens) {
+  console.log(tokens.length);
+});
+ +
+ +
+ + +
+ + + +

getBrandingSettings(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the branding settings..

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters.

+ +
data + + +object + + + + + + + + + + +

Branding data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getBrandingSettings(data, function (err, branding) {
+  if (err) {
+    // Handle error.
+  }
+
+// Branding
+   console.log(branding);
+});
+ +
+ +
+ + +
+ + + +

getBrandingUniversalLoginTemplate(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the new universal login template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters (leave empty).

+ +
data + + +object + + + + + + + + + + +

Branding data (leave empty).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getBrandingUniversalLoginTemplate(data, function (err, template) {
+  if (err) {
+    // Handle error.
+  }
+
+// Branding
+   console.log(template);
+});
+ +
+ +
+ + +
+ + + +

getClient(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
client_id + + +string + + + + +

Application client ID.

+ +
fields + + +string + + + + +

Comma-separated list of fields to include or exclude (based on value provided for include_fields).

+ +
include_fields + + +string + + + + +

Whether specified fields are to be included (true) or excluded (false).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getClient({ client_id: CLIENT_ID }, function (err, client) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(client);
+});
+ +
+ +
+ + +
+ + + +

getClientGrants(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Auth0 Client Grants.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Client Grants parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.getClientGrants(params, function (err, grants) {
+  console.log(grants.length);
+});
+ +
+ +
+ + +
+ + + +

getClients(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Auth0 clients.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Clients parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.getClients(params, function (err, clients) {
+  console.log(clients.length);
+});
+ +
+ +
+ + +
+ + + +

getConnection(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Connection parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Connection ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getConnection({ id: CONNECTION_ID }, function (err, connection) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(connection);
+});
+ +
+ +
+ + +
+ + + +

getConnections(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all connections.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Connections params.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.getConnections(params, function (err, connections) {
+  console.log(connections.length);
+});
+ +
+ +
+ + +
+ + + +

getCustomDomain(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a Custom Domain.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Custom Domain parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Custom Domain ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(customDomain);
+});
+ +
+ +
+ + +
+ + + +

getCustomDomains() → {Promise|undefined}

+ + + + + +
+

Get all Auth0 CustomDomains.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getCustomDomains(function (err, customDomains) {
+  console.log(customDomains.length);
+});
+ +
+ +
+ + +
+ + + +

getCustomTextByLanguage(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Retrieve custom text for a specific prompt and language.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
prompt + + +string + + + + +

Name of the prompt.

+ +
language + + +string + + + + +

Language to retrieve.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { prompt: PROMPT_NAME, language: LANGUAGE };
+
+management.prompts.getCustomTextByLanguage(params, function (err, customText) {
+ console.log('CustomText', customText);
+});
+ +
+ +
+ + +
+ + + +

getDailyStats(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the daily stats.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Stats parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
from + + +string + + + + +

The first day in YYYYMMDD format.

+ +
to + + +string + + + + +

The last day in YYYYMMDD format.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  from: '{YYYYMMDD}',  // First day included in the stats.
+  to: '{YYYYMMDD}'  // Last day included in the stats.
+};
+
+management.getDaily(params, function (err, stats) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(stats);
+});
+ +
+ +
+ + +
+ + + +

getDeviceCredentials(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Auth0 credentials.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Credential parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {user_id: "USER_ID"};
+
+management.getDeviceCredentials(params, function (err, credentials) {
+  console.log(credentials.length);
+});
+ +
+ +
+ + +
+ + + +

getEmailProvider(cbopt, paramsopt) → {Promise|undefined}

+ + + + + +
+

Get the email provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
params + + +object + + + + + + <optional>
+ + + + + +
+

Clients parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
fields + + +number + + + + + + <optional>
+ + + + + +
+

A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields.

+ +
include_fields + + +number + + + + + + <optional>
+ + + + + +
+

true if the fields specified are to be excluded from the result, false otherwise (defaults to true)

+ +
+ + +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getEmailProvider(function (err, provider) {
+  console.log(provider.length);
+});
+ +
+ +
+ + +
+ + + +

getEmailTemplate(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 Email Template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Email Template parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Template Name

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getEmailTemplate({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(emailTemplate);
+});
+ +
+ +
+ + +
+ + + +

getGrants(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Auth0 Grants.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Grants parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
per_page + + +number + + + + +

Number of results per page.

+ +
page + + +number + + + + +

Page number, zero indexed.

+ +
include_totals + + +boolean + + + + +

true if a query summary must be included in the result, false otherwise. Default false;

+ +
user_id + + +string + + + + +

The user_id of the grants to retrieve.

+ +
client_id + + +string + + + + +

The client_id of the grants to retrieve.

+ +
audience + + +string + + + + +

The audience of the grants to retrieve.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  per_page: 10,
+  page: 0,
+  include_totals: true,
+  user_id: USER_ID,
+  client_id: CLIENT_ID,
+  audience: AUDIENCE
+};
+
+management.getGrants(params, function (err, grants) {
+  console.log(grants.length);
+});
+ +
+ +
+ + +
+ + + +

getGuardianEnrollment(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a single Guardian enrollment.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The Guardian enrollment data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The Guardian enrollment id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) {
+  console.log(enrollment);
+});
+ +
+ +
+ + +
+ + + +

getGuardianEnrollments(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a list of a user's Guardian enrollments.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
+  console.log(enrollments);
+});
+ +
+ +
+ + +
+ + + +

getGuardianFactorProvider(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Guardian factor provider configuration

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor provider parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) {
+  console.log(provider);
+});
+ +
+ +
+ + +
+ + + +

getGuardianFactors(cbopt) → {Promise|undefined}

+ + + + + +
+

Get a list of Guardian factors and statuses.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getGuardianFactors(function (err, factors) {
+  console.log(factors.length);
+});
+ +
+ +
+ + +
+ + + +

getGuardianFactorSettings(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the settings of a Guardian factor.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getGuardianFactorSettings({ name: 'duo' }, function (err, settings) {
+  console.log(settings);
+});
+ +
+ +
+ + +
+ + + +

getGuardianFactorTemplates(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Guardian enrollment and verification factor templates

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getGuardianFactorTemplates({ name: 'sms' }, function (err, templates) {
+  console.log(templates);
+});
+ +
+ +
+ + +
+ + + +

getGuardianPhoneFactorMessageTypes(cbopt) → {Promise|undefined}

+ + + + + +
+

Get the Guardian phone factor's message types

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getGuardianPhoneFactorMessageTypes(function (err, messageTypes) {
+  console.log(messageTypes);
+});
+ +
+ +
+ + +
+ + + +

getGuardianPhoneFactorSelectedProvider(cbopt) → {Promise|undefined}

+ + + + + +
+

Get the Guardian phone factor's selected provider

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getGuardianPhoneFactorSelectedProvider(function (err, selectedProvider) {
+  console.log(selectedProvider);
+});
+ +
+ +
+ + +
+ + + +

getGuardianPolicies(cbopt) → {Promise|undefined}

+ + + + + +
+

Get enabled Guardian policies

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getGuardianPolicies(function (err, policies) {
+  console.log(policies);
+});
+ +
+ +
+ + +
+ + + +

getHook(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getHook({ id: HOOK_ID }, function (err, hook) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(hook);
+});
+ +
+ +
+ + +
+ + + +

getHooks(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all hooks.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Hooks parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.getHooks(params, function (err, hooks) {
+  console.log(hooks.length);
+});
+ +
+ +
+ + +
+ + + +

getHookSecrets(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 hook's secrets.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: HOOK_ID }
+management.getHookSecrets(params, function (err, secrets) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(secrets);
+});
+ +
+ +
+ + +
+ + + +

getJob(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a job by its ID.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Job parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Job ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  id: '{JOB_ID}'
+};
+
+management.getJob(params, function (err, job) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Retrieved job.
+  console.log(job);
+});
+ +
+ +
+ + +
+ + + +

getJobErrors(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Given a job ID, retrieve the failed/errored items

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Job parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Job ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  id: '{JOB_ID}'
+};
+
+management.jobs.errors(params, function (err, job) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Retrieved job.
+  console.log(job);
+});
+ +
+ +
+ + +
+ + + +

getLog(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 log.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Log parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Event ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getLog({ id: EVENT_ID }, function (err, log) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(log);
+});
+ +
+ +
+ + +
+ + + +

getLogs(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all logs.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Logs params.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
q + + +string + + + + + + <optional>
+ + + + + +
+

Search Criteria using Query String Syntax

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number. Zero based

+ +
per_page + + +number + + + + + + <optional>
+ + + + + +
+

The amount of entries per page

+ +
sort + + +string + + + + + + <optional>
+ + + + + +
+

The field to use for sorting.

+ +
fields + + +string + + + + + + <optional>
+ + + + + +
+

A comma separated list of fields to include or exclude

+ +
include_fields + + +boolean + + + + + + <optional>
+ + + + + +
+

true if the fields specified are to be included in the result, false otherwise.

+ +
include_totals + + +boolean + + + + + + <optional>
+ + + + + +
+

true if a query summary must be included in the result, false otherwise. Default false

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings and the search query. If pagination options are + not present, the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 2
+};
+
+management.getLogs(params, function (err, logs) {
+  console.log(logs.length);
+});
+ +
+ +
+ + +
+ + + +

getLogStream(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 Log Stream.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Log Stream parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Log Stream ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getLogStream({ id: LOG_STREAM_ID }, function (err, logStream) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(logStream);
+});
+ +
+ +
+ + +
+ + + +

getLogStreams(cbopt) → {Promise|undefined}

+ + + + + +
+

Get all Log Streams.

+

management.getLogStreams( function (err, logStreams) { +console.log(logStreams.length); +});

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+ + +
+ + + +

getMigrations(cbopt) → {Promise|undefined}

+ + + + + +
+

Get migrations flags

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getMigrations(function (err, migrations) {
+  if (err) {
+    // Handle error.
+  }
+
+// Migration flags
+   console.log(migrations.flags);
+});
+ +
+ +
+ + +
+ + + +

getPermissionsInRole(roleIdopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get permissions for a given role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
roleId + + +string + + + + + + <optional>
+ + + + + +
+

Id of the role

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +
var params =  { id :'ROLE_ID'};
+ +

+ This method takes a roleId and + returns all permissions within that role + +

+ +
management.getPermissionsInRole(params, function (err, permissions) {
+  console.log(permissions);
+});
+ +
+ +
+ + +
+ + + +

getPromptsSettings(cbopt) → {Promise|undefined}

+ + + + + +
+

Get prompts settings..

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getPromptsSettings(function (err, settings) {
+console.log(settings);
+});
+ +
+ +
+ + +
+ + + +

getResourceServer(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a Resource Server.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Resource Server parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Resource Server ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getResourceServer({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(resourceServer);
+});
+ +
+ +
+ + +
+ + + +

getResourceServers(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all resource servers.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Resource Servers parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.getResourceServers(params, function (err, resourceServers) {
+  console.log(resourceServers.length);
+});
+ +
+ +
+ + +
+ + + +

getRole(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 role.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Role parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Role ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getRole({ id: ROLE_ID }, function (err, role) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(role);
+});
+ +
+ +
+ + +
+ + + +

getRoles(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all roles.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Roles parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.getRoles(params, function (err, roles) {
+  console.log(roles.length);
+});
+ +
+ +
+ + +
+ + + +

getRule(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 rule.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Rule ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getRule({ id: RULE_ID }, function (err, rule) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(rule);
+});
+ +
+ +
+ + +
+ + + +

getRules(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all rules.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Rules parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.getRules(params, function (err, rules) {
+  console.log(rules.length);
+});
+ +
+ +
+ + +
+ + + +

getRulesConfigs(cbopt) → {Promise|undefined}

+ + + + + +
+

Get rules config.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getRulesConfigs(function (err, rulesConfigs) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Get Rules Configs.
+});
+ +
+ +
+ + +
+ + + +

getTenantSettings(cbopt) → {Promise|undefined}

+ + + + + +
+

Get the tenant settings..

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getSettings(function (err, settings) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(settings);
+});
+ +
+ +
+ + +
+ + + +

getUser(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a user by its id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getUser({ id: USER_ID }, function (err, user) {
+  console.log(user);
+});
+ +
+ +
+ + +
+ + + +

getUserBlocks(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get user blocks by its id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getUserBlocks({ id: USER_ID }, function (err, blocks) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(blocks);
+});
+ +
+ +
+ + +
+ + + +

getUserBlocksByIdentifier(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get user blocks by its identifier.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
identifier + + +string + + + + +

The user identifier, any of: username, phone_number, email.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.getUserBlocksByIdentifier({ identifier: USER_ID }, function (err, blocks) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(blocks);
+});
+ +
+ +
+ + +
+ + + +

getUserLogs(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get user's log events.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Get logs data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

User id.

+ +
per_page + + +number + + + + +

Number of results per page.

+ +
page + + +number + + + + +

Page number, zero indexed.

+ +
sort + + +string + + + + +

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

+ +
include_totals + + +boolean + + + + +

true if a query summary must be included in the result, false otherwise. Default false;

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
+
+management.getUserLogs(params, function (err, logs) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(logs);
+});
+ +
+ +
+ + +
+ + + +

getUserPermissions(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get user's permissions

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Get permissions data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

User id.

+ +
per_page + + +number + + + + +

Number of results per page.

+ +
page + + +number + + + + +

Page number, zero indexed.

+ +
sort + + +string + + + + +

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

+ +
include_totals + + +boolean + + + + +

true if a query summary must be included in the result, false otherwise. Default false;

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
+
+management.getUserPermissions(params, function (err, logs) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(logs);
+});
+ +
+ +
+ + +
+ + + +

getUserRoles(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get user's roles

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Get roles data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

User id.

+ +
per_page + + +number + + + + +

Number of results per page.

+ +
page + + +number + + + + +

Page number, zero indexed.

+ +
sort + + +string + + + + +

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

+ +
include_totals + + +boolean + + + + +

true if a query summary must be included in the result, false otherwise. Default false;

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
+
+management.getUserRoles(params, function (err, logs) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(logs);
+});
+ +
+ +
+ + +
+ + + +

getUsers(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all users.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Users params.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
search_engine + + +number + + + + + + <optional>
+ + + + + +
+

The version of the search engine to use.

+ +
q + + +string + + + + + + <optional>
+ + + + + +
+

User Search string to filter which users are returned. Follows Lucene query string syntax as documented at https://auth0.com/docs/api/management/v2#!/Users/get_users.

+ +
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  search_engine: 'v3',
+  q: 'name:*jane*',
+  per_page: 10,
+  page: 0
+};
+
+auth0.getUsers(params, function (err, users) {
+  console.log(users.length);
+});
+ +
+ +
+ + +
+ + + +

getUsersByEmail(emailopt, optionsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get users for a given email address

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
email + + +string + + + + + + <optional>
+ + + + + +
+

Email address of user(s) to find

+ +
options + + +object + + + + + + <optional>
+ + + + + +
+

Additional options to pass to the endpoint

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
fields + + +string + + + + + + <optional>
+ + + + + +
+

Comma-separated list of fields to include or exclude in the result

+ +
include_fields + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether specified fields are to be included (true) or excluded (false). Defaults to true.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an email address as the first argument, + and returns all users with that email address +

+ +
auth0.getUsersByEmail(email, function (err, users) {
+  console.log(users);
+});
+ +
+ +
+ + +
+ + + +

getUsersInRole(idopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get users in a given role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
id + + +string + + + + + + <optional>
+ + + + + +
+

Id of the role

+ +
params.per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
params.page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
params.from + + +string + + + + + + <optional>
+ + + + + +
+

Optional id from which to start selection.

+ +
params.take + + +number + + + + + + <optional>
+ + + + + +
+

The total amount of entries to retrieve when using the from parameter. Defaults to 50.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +
var params = {
+  id: 'ROLE_ID',
+  per_page: 50,
+  page: 0
+};
+ +

+ This method takes a roleId and returns all users within that role. Supports offset (page, per_page) and checkpoint pagination (from, take). You must use checkpoint pagination to retrieve beyond the first 1000 records. +

+ +
management.getUsersInRole(params, function (err, users) {
+  console.log(users);
+});
+ +
+ +
+ + +
+ + + +

importUsers(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Given a path to a file and a connection id, create a new job that imports the +users contained in the file or JSON string and associate them with the given +connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Users import data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
connection_id + + +string + + + + + + + + + + +

connection_id of the connection to which users will be imported.

+ +
users + + +string + + + + + + <optional>
+ + + + + +
+

Path to the users data file. Either users or users_json is mandatory.

+ +
users_json + + +string + + + + + + <optional>
+ + + + + +
+

JSON data for the users.

+ +
upsert + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to update users if they already exist (true) or to ignore them (false).

+ +
send_completion_email + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to send a completion email to all tenant owners when the job is finished (true) or not (false).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  connection_id: '{CONNECTION_ID}',
+  users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}'
+};
+
+management.importUsers(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

importUsersJob(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Given a path to a file and a connection id, create a new job that imports the +users contained in the file or JSON string and associate them with the given +connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Users import data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
connection_id + + +string + + + + + + + + + + +

connection_id of the connection to which users will be imported.

+ +
users + + +string + + + + + + <optional>
+ + + + + +
+

Path to the users data file. Either users or users_json is mandatory.

+ +
users_json + + +string + + + + + + <optional>
+ + + + + +
+

JSON data for the users.

+ +
upsert + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to update users if they already exist (true) or to ignore them (false).

+ +
send_completion_email + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to send a completion email to all tenant owners when the job is finished (true) or not (false).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  connection_id: '{CONNECTION_ID}',
+  users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}'
+};
+
+management.importUsersJob(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

invalidateRememberBrowser(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Invalidate all remembered browsers for MFA.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.invalidateRememberBrowser({ id: USER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Invalidated all remembered browsers.
+});
+ +
+ +
+ + +
+ + + +

linkUsers(userId, params, cbopt) → {Promise|undefined}

+ + + + + +
+

Link the user with another account.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userId + + +string + + + + + + + + + + +

ID of the primary user.

+ +
params + + +object + + + + + + + + + + +

Secondary user data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
user_id + + +string + + + + +

ID of the user to be linked.

+ +
connection_id + + +string + + + + +

ID of the connection to be used.

+ +
provider + + +string + + + + +

Identity provider of the secondary user account being linked.

+ +
link_with + + +string + + + + +

JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var userId = 'USER_ID';
+var params = {
+  user_id: 'OTHER_USER_ID',
+  connection_id: 'CONNECTION_ID'
+};
+
+management.linkUsers(userId, params, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Users linked.
+});
+ +
+ +
+ + +
+ + + +

regenerateRecoveryCode(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Generate new Guardian recovery code.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.regenerateRecoveryCode({ id: USER_ID }, function (err, newRecoveryCode) {
+  console.log(newRecoveryCode);
+});
+ +
+ +
+ + +
+ + + +

removeHookSecrets(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Secrets key/value pairs

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: HOOK_ID }
+var data = ['API_TOKEN', 'DB_PASSWORD']
+auth0.removeHookSecrets(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Hook deleted.
+});
+ +
+ +
+ + +
+ + + +

removePermissionsFromRole(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Remove permissions from a role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params.id + + +string + + + + + + + + + + +

ID of the Role.

+ +
data + + +object + + + + + + + + + + +

permissions data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permissions + + +string + + + + +

Array of permissions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permission_name + + +string + + + + +

Name of a permission

+ +
resource_server_identifier + + +string + + + + +

Identifier for a resource

+ +
+ + +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id :'ROLE_ID'};
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.removePermissionsFromRole(params, data, function (err, permissions) {
+  console.log(permissions);
+});
+ +
+ +
+ + +
+ + + +

removePermissionsFromUser(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Remove permissions from a user

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

params object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

user_id

+ +
+ + +
data + + +string + + + + + + + + + + +

data object containing list of permission IDs

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permissions + + +string + + + + +

Array of permission IDs

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var parms =  { id : 'USER_ID'};
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.removePermissionsFromUser(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User assigned permissions.
+});
+ +
+ +
+ + +
+ + + +

removeRolesFromUser(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Remove roles from a user

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

params object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

user_id

+ +
+ + +
data + + +string + + + + + + + + + + +

data object containing list of role IDs

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
roles + + +string + + + + +

Array of role IDs

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var parms =  { id : 'USER_ID'};
+var data = { "roles" :["role1"]};
+
+management.removeRolesFromUser(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User assigned roles.
+});
+ +
+ +
+ + +
+ + + +

sendEmailVerification(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Send a verification email to a user.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

User data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
user_id + + +string + + + + + + + + + + +

ID of the user to be verified.

+ +
organization_id + + +string + + + + + + <optional>
+ + + + + +
+

Organization ID

+ +
client_id + + +string + + + + + + <optional>
+ + + + + +
+

client_id of the client (application). If no value provided, the global Client ID will be used.

+ +
identity + + +object + + + + + + <optional>
+ + + + + +
+

Used to verify secondary, federated, and passwordless-email identities.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
user_id + + +string + + + + +

user_id of the identity.

+ +
provider + + +string + + + + +

provider of the identity.

+ +
+ + +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+	user_id: '{USER_ID}'
+};
+
+management.sendEmailVerification(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

setBrandingUniversalLoginTemplate(params, template, cbopt) → {Promise|undefined}

+ + + + + +
+

Set the new universal login template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters (leave empty).

+ +
template + + +object + + + + + + + + + + +

Branding data (object with template field).

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.setBrandingUniversalLoginTemplate({}, { template: "a template" }, function (err, template) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

setRulesConfig(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Set a new rules config.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule Config parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +string + + + + +

Rule Config key.

+ +
+ + +
data + + +object + + + + + + + + + + +

Rule Config Data parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +string + + + + +

Rule Config Data value.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { key: RULE_CONFIG_KEY };
+var data =   { value: RULES_CONFIG_VALUE };
+
+management.setRulesConfig(params, data, function (err, rulesConfig) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Rules Config set.
+});
+ +
+ +
+ + +
+ + + +

unblockUser(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Unblock an user by its id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.unblockUser({ id: USER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User unblocked.
+});
+ +
+ +
+ + +
+ + + +

unblockUserByIdentifier(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Unblock an user by its id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
identifier + + +string + + + + +

The user identifier, any of: username, phone_number, email.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.unblockUserByIdentifier({ identifier: USER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User unblocked.
+});
+ +
+ +
+ + +
+ + + +

unlinkUsers(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Unlink the given accounts.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Linked users data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Primary user ID.

+ +
provider + + +string + + + + +

Identity provider in use.

+ +
user_id + + +string + + + + +

Secondary user ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };
+
+management.unlinkUsers(params, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Users accounts unlinked.
+});
+ +
+ +
+ + +
+ + + +

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the app metadata for a user.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
metadata + + +object + + + + + + + + + + +

New app metadata.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID };
+var metadata = {
+  foo: 'bar'
+};
+
+management.updateAppMetadata(params, metadata, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Updated user.
+  console.log(user);
+});
+ +
+ +
+ + +
+ + + +

updateBrandingSettings(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the branding settings.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Branding parameters.

+ +
data + + +object + + + + + + + + + + +

Updated branding data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateBrandingSettings(data, function (err, branding) {
+  if (err) {
+    // Handle error.
+  }
+
+// Updated branding
+   console.log(branding);
+});
+ +
+ +
+ + +
+ + + +

updateClient(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an Auth0 client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
client_id + + +string + + + + +

Application client ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated client data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'newClientName' };
+var params = { client_id: CLIENT_ID };
+
+management.updateClient(params, data, function (err, client) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(client.name);  // 'newClientName'
+});
+ +
+ +
+ + +
+ + + +

updateClientGrant(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an Auth0 client grant.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Client parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Client grant ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated client data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = {
+  client_id: CLIENT_ID,
+  audience: AUDIENCE,
+  scope: []
+};
+var params = { id: CLIENT_GRANT_ID };
+
+management.clientGrants.update(params, data, function (err, grant) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(grant.id);
+});
+ +
+ +
+ + +
+ + + +

updateConnection(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing connection.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Connection parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Connection ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated connection data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'newConnectionName' };
+var params = { id: CONNECTION_ID };
+
+management.updateConnection(params, data, function (err, connection) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(connection.name);  // 'newConnectionName'
+});
+ +
+ +
+ + +
+ + + +

updateCustomTextByLanguage(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Set custom text for a specific prompt.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
prompt + + +string + + + + +

Name of the prompt.

+ +
language + + +string + + + + +

Language to retrieve.

+ +
body + + +object + + + + +

An object containing custom dictionaries for a group of screens.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT };
+
+management.prompts.updateCustomTextByLanguage(params, function (err, customText) {
+console.log('CustomText', customText);
+});
+ +
+ +
+ + +
+ + + +

updateEmailProvider(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the email provider.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Email provider parameters.

+ +
data + + +object + + + + + + + + + + +

Updated email provider data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateEmailProvider(params, data, function (err, provider) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Updated email provider.
+  console.log(provider);
+});
+ +
+ +
+ + +
+ + + +

updateEmailTemplate(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing Email Template.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Email Template parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Template Name

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated Email Template data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { from: 'new@email.com' };
+var params = { name: EMAIL_TEMPLATE_NAME };
+
+management.updateEmailTemplates(params, data, function (err, emailTemplate) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(emailTemplate.from);  // 'new@email.com'
+});
+ +
+ +
+ + +
+ + + +

updateGuardianFactor(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update Guardian Factor

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
data + + +object + + + + + + + + + + +

Updated factor data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateGuardianFactor({ name: 'sms' }, {
+  enabled: true
+}, function (err, factor) {
+  console.log(factor);
+});
+ +
+ +
+ + +
+ + + +

updateGuardianFactorProvider(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update Guardian's factor provider

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor provider parameters.

+ +
data + + +object + + + + + + + + + + +

Updated Factor provider data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateGuardianFactorProvider({ name: 'sms', provider: 'twilio' }, {
+  messaging_service_sid: 'XXXXXXXXXXXXXX',
+  auth_token: 'XXXXXXXXXXXXXX',
+  sid: 'XXXXXXXXXXXXXX'
+}, function (err, provider) {
+  console.log(provider);
+});
+ +
+ +
+ + +
+ + + +

updateGuardianFactorSettings(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update a Guardian's factor settings

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
data + + +object + + + + + + + + + + +

Updated Factor settings data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateGuardianFactorSettings(
+ { name: 'webauthn-roaming' },
+ { userVerification: 'discouraged', overrideRelyingParty: false },
+ function (err, settings) {
+  console.log(settings);
+})
+ +
+ +
+ + +
+ + + +

updateGuardianFactorTemplates(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update Guardian enrollment and verification factor templates

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Factor parameters.

+ +
data + + +object + + + + + + + + + + +

Updated factor templates data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateGuardianFactorTemplates({ name: 'sms' }, {
+  enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.",
+  verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}"
+}, function (err, templates) {
+  console.log(templates);
+});
+ +
+ +
+ + +
+ + + +

updateGuardianPhoneFactorMessageTypes(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the Guardian phone factor's message types

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Parameters.

+ +
data + + +object + + + + + + + + + + +

Updated selected provider data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
message_types + + +Array.<string> + + + + +

Message types (only "sms" and "voice" are supported).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateGuardianPhoneFactorMessageTypes({}, {
+  message_types: ['sms', 'voice']
+}, function (err, factor) {
+  console.log(factor);
+});
+ +
+ +
+ + +
+ + + +

updateGuardianPhoneFactorSelectedProvider(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the Guardian phone factor's selected provider

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Parameters.

+ +
data + + +object + + + + + + + + + + +

Updated selected provider data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
provider + + +string + + + + +

Name of the selected provider

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateGuardianPhoneFactorSelectedProvider({}, {
+  provider: 'twilio'
+}, function (err, factor) {
+  console.log(factor);
+});
+ +
+ +
+ + +
+ + + +

updateGuardianPolicies(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update enabled Guardian policies

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Parameters.

+ +
data + + +Array.<string> + + + + + + + + + + +

Policies to enable. Empty array disables all policies.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateGuardianPolicies({}, [
+  'all-applications'
+], function (err, policies) {
+  console.log(policies);
+});
+ +
+ +
+ + +
+ + + +

updateHook(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated hook data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: HOOK_ID };
+var data = { name: 'my-hook'};
+management.updateHook(params, data, function (err, hook) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(hook.name); // 'my-hook'.
+});
+ +
+ +
+ + +
+ + + +

updateHookSecrets(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing hook.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Hook parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Hook ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Secrets key/value pairs

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: HOOK_ID };
+var data = { API_TOKEN: 'updated-secret'};
+management.updateHookSecrets(params, data, function (err, secrets) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(secrets)
+});
+ +
+ +
+ + +
+ + + +

updateLogStream(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing Log Stream.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Rule ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated rule data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: LOG_STREAM_ID };
+var data = { name: 'my-log-stream'};
+management.updateLogStream(params, data, function (err, logStream) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(logStream.name); // 'my-log-stream'.
+});
+ +
+ +
+ + +
+ + + +

updateMigrations(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the tenant migrations.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Updated migrations data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
data = { flags: { migration: true } };
+management.updateMigrations(data, function (err, migrations) {
+  if (err) {
+    // Handle error.
+  }
+
+// Updated migrations flags
+   console.log(migrations.flags);
+});
+ +
+ +
+ + +
+ + + +

updatePromptsSettings(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update prompts settings.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The new prompts settings.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updatePromptsSettings(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

updateResourceServer(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing resource server.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Resource Server parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Resource Server ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated Resource Server data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'newResourceServerName' };
+var params = { id: RESOURCE_SERVER_ID };
+
+management.updateResourceServer(params, data, function (err, resourceServer) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(resourceServer.name);  // 'newResourceServerName'
+});
+ +
+ +
+ + +
+ + + +

updateRole(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing role.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Role parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Role ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated role data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: ROLE_ID };
+var data = { name: 'my-role'};
+management.updateRole(params, data, function (err, role) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(role.name); // 'my-role'.
+});
+ +
+ +
+ + +
+ + + +

updateRule(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing rule.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Rule ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated rule data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: RULE_ID };
+var data = { name: 'my-rule'};
+management.updateRule(params, data, function (err, rule) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(rule.name); // 'my-rule'.
+});
+ +
+ +
+ + +
+ + + +

updateTenantSettings(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the tenant settings.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The new tenant settings.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.updateTenantSettings(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

updateUser(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update a user by its id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
data + + +object + + + + + + + + + + +

New user data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID };
+
+management.updateUser(params, data, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Updated user.
+  console.log(user);
+});
+ +
+ +
+ + +
+ + + +

updateUserMetadata(params, metadata, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the user metadata for a user.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
metadata + + +object + + + + + + + + + + +

New user metadata.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { id: USER_ID };
+var metadata = {
+  address: '123th Node.js Street'
+};
+
+management.updateUserMetadata(params, metadata, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Updated user.
+  console.log(user);
+});
+ +
+ +
+ + +
+ + + +

verifyCustomDomain(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Verify a Custom Domain.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Custom Domain parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Custom Domain ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.verifyCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(customDomain);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/ManagementTokenProvider.html b/docs/ManagementTokenProvider.html new file mode 100644 index 000000000..033dfaa43 --- /dev/null +++ b/docs/ManagementTokenProvider.html @@ -0,0 +1,680 @@ + + + + + + ManagementTokenProvider - Documentation + + + + + + + + + + + + + + + + + +
+ +

ManagementTokenProvider

+ + + + + + + +
+ +
+ +

+ ManagementTokenProvider +

+ +

Auth0 Management API Token Provider.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new ManagementTokenProvider(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

Options for the ManagementTokenProvider.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDefaultDescription
domain + + +string + + + + + + + + + + + + +

ManagementClient server domain.

+ +
clientId + + +string + + + + + + + + + + + + +

Non Interactive Client Id.

+ +
clientSecret + + +string + + + + + + + + + + + + +

Non Interactive Client Secret.

+ +
scope + + +string + + + + + + + + + + + + +

Non Interactive Client Scope.

+ +
audience + + +string + + + + + + + + + + + + +

Audience of the Management API.

+ +
enableCache + + +boolean + + + + + + <optional>
+ + + + + +
+ + true + + +

Enabled or Disable Cache

+ +
cacheTTLInSeconds + + +number + + + + + + <optional>
+ + + + + +
+ + +

By default the expires_in value will be used to determine the cached time of the token, this can be overridden.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+ + +

Additional headers that will be added to the outgoing requests.

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

(async) getAccessToken() → {Promise}

+ + + + + +
+

Returns the access_token.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise + + +
+
+ + +
+

Promise returning an access_token.

+
+ + +
+ + + +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/MigrationsManager.html b/docs/MigrationsManager.html new file mode 100644 index 000000000..89d35ce17 --- /dev/null +++ b/docs/MigrationsManager.html @@ -0,0 +1,922 @@ + + + + + + MigrationsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

MigrationsManager

+ + + + + + + +
+ +
+ +

+ MigrationsManager +

+ +

Abstracts interaction with the migrations endpoint.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new MigrationsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the migrations endpoint

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

getMigrations(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the tenant migrations.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + + + + + + + + + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.migrations.getMigrations(function (err, migrations) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(migrations.flags);
+});
+ +
+ +
+ + +
+ + + +

updateMigrations(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the tenant migrations.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The tenant migrations to be updated

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
flags + + +object + + + + +

The tenant migrations flags to be updated

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.migrations.updateMigrations(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/OAUthWithIDTokenValidation.html b/docs/OAUthWithIDTokenValidation.html new file mode 100644 index 000000000..b161cbcaa --- /dev/null +++ b/docs/OAUthWithIDTokenValidation.html @@ -0,0 +1,701 @@ + + + + + + OAUthWithIDTokenValidation - Documentation + + + + + + + + + + + + + + + + + +
+ +

OAUthWithIDTokenValidation

+ + + + + + + +
+ +
+ +

+ OAUthWithIDTokenValidation +

+ +

Abstracts the oauth.create method with additional id_token validation

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new OAUthWithIDTokenValidation(oauth, options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
oauth + + +object + + + + +

An instance of @type {OAuthAuthenticator}

+ +
options + + +object + + + + +

Authenticator options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
domain + + +string + + + + + + + + + + +

AuthenticationClient server domain

+ +
clientId + + +string + + + + + + <optional>
+ + + + + +
+

Default client ID.

+ +
clientSecret + + +string + + + + + + <optional>
+ + + + + +
+

Default client Secret.

+ +
supportedAlgorithms + + +string + + + + + + <optional>
+ + + + + +
+

Algorithms that your application expects to receive

+ +
__bypassIdTokenValidation + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether the id_token should be validated or not

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

create(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Creates an oauth request and validates the id_token (if any)

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

OAuth parameters that are passed through

+ +
data + + +object + + + + + + + + + + +

Custom parameters sent to the OAuth endpoint

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/OAuthAuthenticator.html b/docs/OAuthAuthenticator.html new file mode 100644 index 000000000..b8e0b0f30 --- /dev/null +++ b/docs/OAuthAuthenticator.html @@ -0,0 +1,2178 @@ + + + + + + OAuthAuthenticator - Documentation + + + + + + + + + + + + + + + + + +
+ +

OAuthAuthenticator

+ + + + + + + +
+ +
+ +

+ OAuthAuthenticator +

+ +

Abstracts the sign-in, sign-up and change-password processes for Database & +Active Directory authentication services.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new OAuthAuthenticator(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

Authenticator options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The Auth0 account URL.

+ +
domain + + +string + + + + + + + + + + +

AuthenticationClient server domain

+ +
clientId + + +string + + + + + + <optional>
+ + + + + +
+

Default client ID.

+ +
clientSecret + + +string + + + + + + <optional>
+ + + + + +
+

Default client Secret.

+ +
__bypassIdTokenValidation + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether the id_token should be validated or not

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

authorizationCodeGrant(options, cb) → {Promise|undefined}

+ + + + + +
+

Sign in using an authorization code

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

Authorization code payload

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
organization + + +string + + + + +

Organization ID

+ +
code + + +string + + + + +

Code in URL returned after authentication

+ +
redirect_uri + + +string + + + + +

The URL to which Auth0 will redirect the browser after authorization has been granted by the user.

+ +
+ + +
cb + + +function + + + + +

Callback

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the code returned in the URL params after the redirect + from successful authentication, exchange the code for auth0 + credentials. It will return JSON with the access_token and id_token. + More information in the + + API Docs + . +

+ +
var options = {
+  code: '{CODE}',
+  redirect_uri: '{REDIRECT_URI}',
+  organization: '{ORGANIZATION_ID}' // Optiional field.
+};
+
+auth0.oauth.authorizationCodeGrant(options, function (err, userData) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(userData);
+});
+ +
+ +
+ + +
+ + + +

passwordGrant(userData, optionsopt, cb) → {Promise|undefined}

+ + + + + +
+

Sign in using a username and password

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
username + + +string + + + + + + + + + + +

Username.

+ +
password + + +string + + + + + + + + + + +

User password.

+ +
realm + + +string + + + + + + <optional>
+ + + + + +
+

Name of the realm to use to authenticate or the connection name

+ +
+ + +
options + + +object + + + + + + <optional>
+ + + + + +
+

Additional options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
forwardedFor + + +string + + + + + + <optional>
+ + + + + +
+

Value to be used for auth0-forwarded-for header

+ +
+ + +
cb + + +function + + + + + + + + + + +

Callback

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user's credentials perform the OAuth password grant + or Password Realm grant if a realm is provided, + it will return a JSON with the access_token and id_token. + + More information in the + + API Docs + . +

+ +
var data = {
+  client_id: '{CLIENT_ID}',  // Optional field.
+  username: '{USERNAME}',
+  password: '{PASSWORD}',
+  realm: '{CONNECTION_NAME}', // Optional field.
+  scope: 'openid'  // Optional field.
+};
+
+auth0.oauth.passwordGrant(data, function (err, userData) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(userData);
+});
+ +
+ +
+ + +
+ + + +

refreshToken(data, cb) → {Promise|undefined}

+ + + + + +
+

Exchange a refresh token

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
data + + +object + + + + +

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
refresh_token + + +string + + + + +

Refresh token.

+ +
+ + +
cb + + +function + + + + +

Callback

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given a refresh token from a previous authentication request + it will return a JSON with the access_token and id_token if + the openid scope was originally included. + More information in the + + API Docs + . +

+ +
var data = {
+  refresh_token: '{REFRESH_TOKEN}',
+};
+
+auth0.oauth.refreshToken(data, function (err, data) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(data);
+});
+ +
+ +
+ + +
+ + + +

signIn(userData, optionsopt, cb) → {Promise|undefined}

+ + + + + +
+

Sign in using a username and password.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
username + + +string + + + + +

Username.

+ +
password + + +string + + + + +

User password.

+ +
connection + + +string + + + + +

The identity provider in use.

+ +
+ + +
options + + +object + + + + + + <optional>
+ + + + + +
+

Additional options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
forwardedFor + + +string + + + + + + <optional>
+ + + + + +
+

Value to be used for auth0-forwarded-for header

+ +
+ + +
cb + + +function + + + + + + + + + + +

Callback

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user's credentials and the connection specified, it + will return a JSON with the access_token and id_token. + More information in the + + + API Docs + . +

+ +
var data = {
+  client_id: '{CLIENT_ID}',  // Optional field.
+  username: '{USERNAME}',
+  password: '{PASSWORD}',
+  connection: '{CONNECTION_NAME}',
+  scope: 'openid'  // Optional field.
+};
+
+auth0.oauth.signIn(data, function (err, userData) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(userData);
+});
+ +
+ +
+ + +
+ + + +

socialSignIn(data, cb) → {Promise|undefined}

+ + + + + +
+

Sign in using a social provider access token.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
data + + +object + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
access_token + + +string + + + + +

User access token.

+ +
connection + + +string + + + + +

Identity provider.

+ +
+ + +
cb + + +function + + + + +

Callback

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/OrganizationsManager.html b/docs/OrganizationsManager.html new file mode 100644 index 000000000..898bbaaa9 --- /dev/null +++ b/docs/OrganizationsManager.html @@ -0,0 +1,7835 @@ + + + + + + OrganizationsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

OrganizationsManager

+ + + + + + + +
+ +
+ +

+ OrganizationsManager +

+ +

The organizations class provides a simple abstraction for performing CRUD operations +on Auth0 OrganizationsManager.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new OrganizationsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

organizations :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +https://auth0.com/docs/api/v2.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

addEnabledConnection(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Add an enabled connection for an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
+ + +
data + + +object + + + + + + + + + + +

enable connection data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
connection_id + + +string + + + + +

connection ID to enable

+ +
assign_membership_on_login + + +boolean + + + + +

flag to allow assign membership on login

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ORGANIZATION_ID'};
+var data = { "connection_id" : "CONNECTION_ID", assign_membership_on_login: false };
+
+management.organizations.addEnabledConnection(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

addMemberRoles(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Add a Role to a Member in an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
user_id + + +string + + + + +

ID of the user.

+ +
+ + +
data + + +object + + + + + + + + + + +

Add member roles data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
roles + + +Array + + + + +

Array of role IDs.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  {id : 'ORGANIZATION_ID', user_id: 'user_id'};
+var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
+
+management.organizations.addMemberRoles(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

addMembers(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Add members in an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
+ + +
data + + +object + + + + + + + + + + +

add members data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
members + + +Array + + + + +

Array of user IDs

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ORGANIZATION_ID'};
+var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
+management.organizations.addMembers(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new organization.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Organization data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.organizations.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Organization created.
+});
+ +
+ +
+ + +
+ + + +

createInvitation(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an invitation in an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
+ + +
data + + +Array + + + + + + + + + + +

Invitation data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
inviter + + +object + + + + + + + + + + +

The person who is sending the invite.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Name of the person who is sending the invite

+ +
+ + +
invitee + + +object + + + + + + + + + + +

Invitee to whom invitation is intended for

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +object + + + + +

Email of the invitee to whom invitation is intended for

+ +
+ + +
client_id + + +string + + + + + + + + + + +

Auth0 client used to resolve the default application login URI. This endpoint must expect &invitation=... and &organization=... parameters (added by API2) to continue the flow with /authorize. If client_id does not have configured login URI, use the tenant level default login route if configured, otherwise return 400

+ +
connection_id + + +string + + + + + + <optional>
+ + + + + +
+

Force user to authenticate against a specific identity provider.

+ +
app_metadata + + +object + + + + + + <optional>
+ + + + + +
+

Application metadata to be assigned to the user after accept the invitation.

+ +
user_metadata + + +object + + + + + + <optional>
+ + + + + +
+

User metadata to be assigned to the user after accept the invitation.

+ +
roles + + +Array + + + + + + <optional>
+ + + + + +
+

List of roles to be assigned to the user

+ +
ttl_sec + + +number + + + + + + <optional>
+ + + + + +
+

Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Upper limit on ttl_sec is 30 days.

+ +
send_invitation_email + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether the user will receive an invitation email (true) or no email (false). Default is true.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ORGANIZATION_ID'};
+var data = {
+  client_id: CLIENT_ID,
+  invitee: { email: 'invitee@example.com' },
+  inviter: { name: 'John Doe' }
+};
+
+management.organizations.createInvitation(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing organization.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Organization ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.organizations.delete({ id: ORGANIZATION_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Organization deleted.
+});
+ +
+ +
+ + +
+ + + +

deleteInvitation(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an invitation from an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
invitation_id + + +string + + + + +

Invitation ID

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ORGANIZATION_ID', invitation_id: 'INVITATION_ID };
+
+management.organizations.deleteInvitation(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all organizations.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Organizations parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
from + + +string + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, the Id from which to start selection from.

+ +
take + + +number + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, the number of entries to retrieve. Default 50.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.organizations.getAll(params, function (err, organizations) {
+  console.log(organizations.length);
+});
+ +
+ +
+ + +
+ + + +

getByID(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 organization.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Organization ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.organizations.getByID({ id: ORGANIZATION_ID }, function (err, role) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(organization);
+});
+ +
+ +
+ + +
+ + + +

getByName(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 organization.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

Organization name.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.organizations.getByName({ name: ORGANIZATION_NAME}, function (err, role) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(organization);
+});
+ +
+ +
+ + +
+ + + +

getEnabledConnection(params, callbackopt) → {Promise|undefined}

+ + + + + +
+

Get Enabled Connection in a Organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Organization ID.

+ +
connection_id + + +string + + + + +

Connection ID.

+ +
+ + +
callback + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This methods takes the organization ID and connection ID and returns the enabled connection +

+ +
var params = {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}
+
+management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}, function (err, enabled_connection) {
+  console.log(enabled_connection);
+});
+ +
+ +
+ + +
+ + + +

getEnabledConnections(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Enabled Connections in a Organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Organization ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an organization ID and returns the enabled connections in an Organization +

+ +
var params = {id : 'ORGANIZATION_ID'}
+
+management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID'}, function (err, enabled_connections) {
+  console.log(enabled_connections);
+});
+ +
+ +
+ + +
+ + + +

getInvitation(callback, params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Invitation in a Organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
callback + + + + + + + + + + +
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Organization ID

+ +
invitation_id + + +string + + + + +

Invitation ID

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +
var params = {id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}
+ +

+ This methods takes the organization ID and user ID and returns the invitation +

+ +
management.organizations.getInvitation({id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}, function (err, invite) {
+  console.log(invite);
+});
+ +
+ +
+ + +
+ + + +

getInvitations(callback, params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Invites in a Organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
callback + + + + + + + + +

});

+ +
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
id + + +string + + + + + + + + + + +

Organization ID

+ +
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
from + + +string + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, the Id from which to start selection from.

+ +
take + + +number + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, the number of entries to retrieve. Default 50.

+ +
fields + + +string + + + + + + <optional>
+ + + + + +
+

Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.

+ +
include_fields + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether specified fields are to be included (true) or excluded (false). Defaults to true.

+ +
sort + + +string + + + + + + <optional>
+ + + + + +
+

Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +
var params = {id : 'ORGANIZATION_ID'}
+ +

+ This method takes an organization ID and returns the invites in an Organization +

+ +
management.organizations.getInvitations( {id : 'ORGANIZATION_ID'}, function (err, invites) {
+  console.log(invites);
+ +
+ +
+ + +
+ + + +

getMemberRoles(callback, params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Roles from a Member in a Organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
callback + + + + + + + + + + +
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
user_id + + +string + + + + +

ID of the user.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +
var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'}
+ +

+ This methods takes the organization ID and user ID and returns the roles +

+ +
management.organizations.getMemberRoles( {id : 'ORGANIZATION_ID', user_id: 'user_id'}, function (err, roles) {
+  console.log(roles);
+});
+ +
+ +
+ + +
+ + + +

getMembers(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Members in a Organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
id + + +string + + + + + + + + + + +

Organization ID

+ +
from + + +string + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, the Id from which to start selection from.

+ +
take + + +number + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, the number of entries to retrieve. Default 50.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an organization ID and returns the members in an Organization +

+ +
 var params = {id : 'ORGANIZATION_ID'}
+
+management.organizations.getMembers( {id : 'ORGANIZATION_ID'}, function (err, members) {
+  console.log(members);
+});
+ +
+ +
+ + +
+ + + +

removeEnabledConnection(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Remove an enabled connection from an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
connection_id + + +string + + + + +

ID of the Connection.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
+
+management.organizations.removeEnabledConnection(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

removeMemberRoles(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Remove Roles from a Member of an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
user_id + + +string + + + + +

Id of the User

+ +
+ + +
data + + +object + + + + + + + + + + +

Remove member roles data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
roles + + +Array + + + + +

Array of role IDs.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ORGANIZATION_ID', user_id: 'USER_ID };
+var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
+
+management.organizations.removeMemberRoles(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

removeMembers(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Remove members from an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
+ + +
data + + +object + + + + + + + + + + +

add members data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
members + + +Array + + + + +

Array of user IDs

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ORGANIZATION_ID' };
+var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
+
+management.organizations.removeMembers(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing organization.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Organization ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated organization data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { display_name: 'New name' };
+var params = { id: ORGANIZATION_ID };
+
+management.organizations.update(params, data, function (err, organization) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(organization.name);  // 'New name'
+});
+ +
+ +
+ + +
+ + + +

updateEnabledConnection(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an enabled connection from an organization

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Organization parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

ID of the Organization.

+ +
connection_id + + +string + + + + +

ID of the Connection.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated connection.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
+var data = { assign_membership_on_login: true };
+
+management.organizations.updateEnabledConnection(params, data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/PasswordlessAuthenticator.html b/docs/PasswordlessAuthenticator.html new file mode 100644 index 000000000..4256ef7a8 --- /dev/null +++ b/docs/PasswordlessAuthenticator.html @@ -0,0 +1,1813 @@ + + + + + + PasswordlessAuthenticator - Documentation + + + + + + + + + + + + + + + + + +
+ +

PasswordlessAuthenticator

+ + + + + + + +
+ +
+ +

+ PasswordlessAuthenticator +

+ +

Handles authenticator with passwordless flows, e.g. SMS, Touch ID, etc.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new PasswordlessAuthenticator(options, oauth)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

Authenticator options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The auth0 account URL.

+ +
clientId + + +string + + + + + + <optional>
+ + + + + +
+

Default client ID.

+ +
clientSecret + + +string + + + + + + <optional>
+ + + + + +
+

Default client secret.

+ +
+ + +
oauth + + +OAuthAuthenticator + + + + +

OAuthAuthenticator instance.

+ +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

sendEmail(userData, optionsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Start passwordless flow sending an email.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User account data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +string + + + + +

User email address.

+ +
send + + +string + + + + +

The type of email to be sent.

+ +
+ + +
options + + +object + + + + + + <optional>
+ + + + + +
+

Additional options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
forwardedFor + + +string + + + + + + <optional>
+ + + + + +
+

Value to be used for auth0-forwarded-for header

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user `email` address, it will send an email with: + +

    +
  • A link (default, `send:"link"`). You can then authenticate with this + user opening the link and he will be automatically logged in to the + application. Optionally, you can append/override parameters to the link + (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using + `authParams` object. +
  • +
  • + A verification code (`send:"code"`). You can then authenticate with + this user using the `/oauth/ro` endpoint specifying `email` as + `username` and `code` as `password`. +
  • +
+ + Find more information in the + API Docs +

+ +
var data = {
+  email: '{EMAIL}',
+  send: 'link',
+  authParams: {} // Optional auth params.
+};
+
+auth0.passwordless.sendEmail(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

sendSMS(userData, optionsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Start passwordless flow sending an SMS.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User account data.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
phone_number + + +string + + + + +

User phone number.

+ +
+ + +
options + + +object + + + + + + <optional>
+ + + + + +
+

Additional options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
forwardedFor + + +string + + + + + + <optional>
+ + + + + +
+

Value to be used for auth0-forwarded-for header

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given the user `phone_number`, it will send a SMS message with a + verification code. You can then authenticate with this user using the + `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as + `password`: +

+ +
var data = {
+  phone_number: '{PHONE}'
+};
+
+auth0.passwordless.sendSMS(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

signIn(userData, optionsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Sign in with the given user credentials.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
userData + + +object + + + + + + + + + + +

User credentials object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDefaultDescription
username + + +string + + + + + + + + + + + + +

The user's phone number if realm=sms, or the user's email if realm=email

+ +
otp + + +string + + + + + + + + + + + + +

The user's verification code. Required

+ +
audience + + +string + + + + + + <optional>
+ + + + + +
+ + +

API Identifier of the API for which you want to get an Access Token.

+ +
realm + + +string + + + + + + <optional>
+ + + + + +
+ + sms + + +

Realm string: "sms" or "email".

+ +
password + + +string + + + + + + <optional>
+ + + + + +
+ + +

[DEPRECATED] Password required if using legacy /oauth/ro endpoint

+ +
connection + + +string + + + + + + <optional>
+ + + + + +
+ + sms + + +

[DEPRECATED] Connection string: "sms" or "email".

+ +
+ + +
options + + +object + + + + + + <optional>
+ + + + + +
+

Additional options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
forwardedFor + + +string + + + + + + <optional>
+ + + + + +
+

Value to be used for auth0-forwarded-for header

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +

+Once you have a verification code, use this endpoint to login +the user with their phone number/email and verification code. + +https://auth0.com/docs/api/authentication#authenticate-user +

+ +
var data = {
+  username: '{PHONE_NUMBER OR EMAIL}',
+  otp: '{VERIFICATION_CODE}',
+  realm: '{sms or email}' // OPTIONAL DEFAULTS TO SMS
+};
+
+auth0.passwordless.signIn(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +

+ The user data object has the following structure. +

+ +
{
+  id_token: String,
+  access_token: String,
+  token_type: String
+}
+ +

+ LEGACY signIn using the `/oauth/ro` endpoint. When otp is not specified + password is required. Given the user credentials (`phone_number` and `code`), + it will do the authentication on the provider and return a JSON with + the `access_token` and `id_token`. + +https://auth0.com/docs/api/authentication#resource-owner +

+ +
var data = {
+  username: '{PHONE_NUMBER}',
+  password: '{VERIFICATION_CODE}'
+};
+
+auth0.passwordless.signIn(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/PromptsManager.html b/docs/PromptsManager.html new file mode 100644 index 000000000..a5cf9d91d --- /dev/null +++ b/docs/PromptsManager.html @@ -0,0 +1,1644 @@ + + + + + + PromptsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

PromptsManager

+ + + + + + + +
+ +
+ +

+ PromptsManager +

+ +

Manages settings related to prompts.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new PromptsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

customTextByLanguage :external:RestClient

+ + + + +
+

Retrieve custom text for a specific prompt and language. +Custom Text endpoint

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Prompts endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

getCustomTextByLanguage(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Retrieve custom text for a specific prompt and language.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
prompt + + +string + + + + +

Name of the prompt.

+ +
language + + +string + + + + +

Language to retrieve.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { prompt: PROMPT_NAME, language: LANGUAGE };
+
+management.prompts.getCustomTextByLanguage(params, function (err, customText) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log('CustomText', customText);
+});
+ +
+ +
+ + +
+ + + +

getSettings(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the prompts settings..

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Prompts parameters.

+ +
data + + +object + + + + + + + + + + +

Prompts data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.prompts.getSettings(data, function (err, prompts) {
+  if (err) {
+    // Handle error.
+  }
+
+// Prompts
+   console.log(prompts);
+});
+ +
+ +
+ + +
+ + + +

updateCustomTextByLanguage(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Set custom text for a specific prompt.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
prompt + + +string + + + + +

Name of the prompt.

+ +
language + + +string + + + + +

Language to retrieve.

+ +
body + + +object + + + + +

An object containing custom dictionaries for a group of screens.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT };
+
+management.prompts.updateCustomTextByLanguage(params, function (err, customText) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log('CustomText', customText);
+});
+ +
+ +
+ + +
+ + + +

updateSettings(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the prompts settings.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Prompts parameters.

+ +
data + + +object + + + + + + + + + + +

Updated prompts data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.prompts.updateSettings(params, data, function (err, prompts) {
+  if (err) {
+    // Handle error.
+  }
+
+// Updated prompts
+   console.log(prompts);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/ResourceServersManager.html b/docs/ResourceServersManager.html new file mode 100644 index 000000000..858ce2929 --- /dev/null +++ b/docs/ResourceServersManager.html @@ -0,0 +1,1837 @@ + + + + + + ResourceServersManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

ResourceServersManager

+ + + + + + + +
+ +
+ +

+ ResourceServersManager +

+ +

Auth0 Resource Servers Manager.

+

Resource Servers represents +your APIs. +You can learn more about this in the +API Authorization section of the +documentation.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new ResourceServersManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Auth0 Resource Servers endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create an API (Resource Server).

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Resource Server data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.resourceServers.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Resource Server created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing Resource Server.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Resource Server parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Resource Server ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.resourceServers.delete({ id: RESOURCE_SERVER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Resource Server deleted.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get a Resource Server.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Resource Server parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Resource Server ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.resourceServers.get({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(resourceServer);
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all resource servers.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Resource Servers parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.resourceServers.getAll(params, function (err, resourceServers) {
+  console.log(resourceServers.length);
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing resource server.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Resource Server parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Resource Server ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated Resource Server data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'newResourceServerName' };
+var params = { id: RESOURCE_SERVER_ID };
+
+management.resourceServers.update(params, data, function (err, resourceServer) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(resourceServer.name);  // 'newResourceServernName'
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/RestClient%0A%7B@link%20https___github.com_ngonzalvez_rest-facade%7Dexternal_.html b/docs/RestClient%0A%7B@link%20https___github.com_ngonzalvez_rest-facade%7Dexternal_.html new file mode 100644 index 000000000..0ae860c4f --- /dev/null +++ b/docs/RestClient%0A%7B@link%20https___github.com_ngonzalvez_rest-facade%7Dexternal_.html @@ -0,0 +1,145 @@ + + + + + + RestClient +<a href="https://github.com/ngonzalvez/rest-facade">https://github.com/ngonzalvez/rest-facade</a> - Documentation + + + + + + + + + + + + + + + + + +
+ +

RestClient +https://github.com/ngonzalvez/rest-facade

+ + + + + + + +
+ +
+ +

+ RestClient +https://github.com/ngonzalvez/rest-facade +

+ + +
+ +
+
+ + +

Simple facade for consuming a REST API endpoint.

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/RetryRestClient.html b/docs/RetryRestClient.html new file mode 100644 index 000000000..65ae108b4 --- /dev/null +++ b/docs/RetryRestClient.html @@ -0,0 +1,386 @@ + + + + + + RetryRestClient - Documentation + + + + + + + + + + + + + + + + + +
+ +

RetryRestClient

+ + + + + + + +
+ +
+ +

+ RetryRestClient +

+ +

Wrapper Rest Client that adds Retry functionality when requests are failing due to rate limiting (status code 429).

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new RetryRestClient(restClient, optionsopt)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
restClient + + +object + + + + + + + + + + +

RestClient.

+ +
options + + +object + + + + + + <optional>
+ + + + + +
+

Options for the RetryRestClient. It includes all properties from https://github.com/tim-kos/node-retry#retryoperationoptions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDefaultDescription
enabled + + +object + + + + + + <optional>
+ + + + + +
+ + true + + +

Enabled or Disable Retry Policy functionality.

+ +
maxRetries + + +number + + + + + + <optional>
+ + + + + +
+ + 3 + + +

The maximum amount of times to retry the operation.

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + \ No newline at end of file diff --git a/docs/RetryRestClient.js.html b/docs/RetryRestClient.js.html index 0cf54eb1e..5010e6171 100644 --- a/docs/RetryRestClient.js.html +++ b/docs/RetryRestClient.js.html @@ -24,7 +24,8 @@
@@ -39,160 +40,109 @@

RetryRestClient.js

-
var Promise = require('bluebird');
-var retry = require('retry');
-var ArgumentError = require('rest-facade').ArgumentError;
-var assign = Object.assign || require('object.assign');
+            
const retry = require('retry');
+const { ArgumentError } = require('rest-facade');
 
-var DEFAULT_OPTIONS = { maxRetries: 10, enabled: true };
+const DEFAULT_OPTIONS = {
+  maxRetries: 3,
+  enabled: true,
+  randomize: true,
+};
 
 /**
- * @class RetryRestClient
  * Wrapper Rest Client that adds Retry functionality when requests are failing due to rate limiting (status code 429).
- * @constructor
- * @memberOf module:management
- * @param {Object}  restClient                   RestClient.
- * @param {Object}  [options]                    Options for the RetryRestClient.
- * @param {Object}  [options.enabled:true]       Enabled or Disable Retry Policy functionality.
- * @param {Number}  [options.maxRetries=10]      The maximum amount of times to retry the operation. Default is 10.
  */
-var RetryRestClient = function(restClient, options) {
-  if (restClient === null || typeof restClient !== 'object') {
-    throw new ArgumentError('Must provide RestClient');
-  }
-
-  var params = assign({}, DEFAULT_OPTIONS, options);
-
-  if (typeof params.enabled !== 'boolean') {
-    throw new ArgumentError('Must provide enabled boolean value');
-  }
-
-  if (typeof params.maxRetries !== 'number' || params.maxRetries <= 0) {
-    throw new ArgumentError('Must provide maxRetries as a positive number');
-  }
-
-  this.restClient = restClient;
-  this.maxRetries = params.maxRetries;
-  this.enabled = params.enabled;
-};
-
-RetryRestClient.prototype.getAll = function(/* [params], [callback] */) {
-  return this.invoke('getAll', arguments);
-};
+class RetryRestClient {
+  /**
+   * @param {object}  restClient                   RestClient.
+   * @param {object}  [options]                    Options for the RetryRestClient. It includes all properties from https://github.com/tim-kos/node-retry#retryoperationoptions
+   * @param {object}  [options.enabled=true]       Enabled or Disable Retry Policy functionality.
+   * @param {number}  [options.maxRetries=3]       The maximum amount of times to retry the operation.
+   */
+  constructor(restClient, options) {
+    if (restClient === null || typeof restClient !== 'object') {
+      throw new ArgumentError('Must provide RestClient');
+    }
 
-RetryRestClient.prototype.get = function(/* [params], [callback] */) {
-  return this.invoke('get', arguments);
-};
+    const params = Object.assign({}, DEFAULT_OPTIONS, options);
 
-RetryRestClient.prototype.create = function(/* [params], [callback] */) {
-  return this.invoke('create', arguments);
-};
+    if (typeof params.enabled !== 'boolean') {
+      throw new ArgumentError('Must provide enabled boolean value');
+    }
 
-RetryRestClient.prototype.patch = function(/* [params], [callback] */) {
-  return this.invoke('patch', arguments);
-};
+    if (typeof params.maxRetries !== 'number' || params.maxRetries <= 0) {
+      throw new ArgumentError('Must provide maxRetries as a positive number');
+    }
 
-RetryRestClient.prototype.update = function(/* [params], [callback] */) {
-  return this.invoke('update', arguments);
-};
+    this.restClient = restClient;
+    this.enabled = params.enabled;
+    this.retryOptions = Object.assign({ retries: params.maxRetries }, params);
+  }
 
-RetryRestClient.prototype.delete = function(/* [params], [callback] */) {
-  return this.invoke('delete', arguments);
-};
+  getAll(...args) {
+    return this.invoke('getAll', args);
+  }
 
-RetryRestClient.prototype.invoke = function(method, args) {
-  var cb;
-  args = Array.prototype.slice.call(args); // convert array-like object to array.
-  if (args && args[args.length - 1] instanceof Function) {
-    cb = args[args.length - 1];
-    args.pop(); // Remove the callback
+  get(...args) {
+    return this.invoke('get', args);
   }
 
-  var promise = this.handleRetry(method, args);
+  create(...args) {
+    return this.invoke('create', args);
+  }
 
-  if (cb instanceof Function) {
-    promise.then(cb.bind(null, null)).catch(cb);
-    return;
+  patch(...args) {
+    return this.invoke('patch', args);
   }
 
-  return promise;
-};
+  update(...args) {
+    return this.invoke('update', args);
+  }
 
-RetryRestClient.prototype.handleRetry = function(method, args) {
-  if (!this.enabled) {
-    return this.restClient[method].apply(this.restClient, args);
+  delete(...args) {
+    return this.invoke('delete', args);
   }
 
-  var retryOptions = {
-    retries: this.maxRetries,
-    factor: 1,
-    minTimeout: 1, // retry immediate, use custom logic to control this.
-    randomize: false
-  };
-
-  var self = this;
-  var promise = new Promise(function(resolve, reject) {
-    var operation = retry.operation(retryOptions);
-
-    operation.attempt(function() {
-      self.restClient[method]
-        .apply(self.restClient, args)
-        .then(function(body) {
-          resolve(body);
-        })
-        .catch(function(err) {
-          self.invokeRetry(err, operation, reject);
-        });
-    });
-  });
+  invoke(method, args) {
+    let cb;
+    if (args && args[args.length - 1] instanceof Function) {
+      cb = args[args.length - 1];
+      args.pop(); // Remove the callback
+    }
 
-  return promise;
-};
+    const promise = this.handleRetry(method, args);
 
-RetryRestClient.prototype.invokeRetry = function(err, operation, reject) {
-  var ratelimits = this.extractRatelimits(err);
-  if (ratelimits) {
-    var delay = ratelimits.reset * 1000 - new Date().getTime();
-    if (delay > 0) {
-      this.retryWithDelay(delay, operation, err, reject);
-    } else {
-      this.retryWithImmediate(operation, err, reject);
+    if (cb instanceof Function) {
+      promise.then(cb.bind(null, null)).catch(cb);
+      return;
     }
-  } else {
-    reject(err);
-  }
-};
 
-RetryRestClient.prototype.extractRatelimits = function(err) {
-  if (err && err.statusCode === 429 && err.originalError && err.originalError.response) {
-    var headers = err.originalError.response.header;
-    if (headers && headers['x-ratelimit-limit']) {
-      return {
-        limit: headers['x-ratelimit-limit'],
-        remaining: headers['x-ratelimit-remaining'],
-        reset: headers['x-ratelimit-reset']
-      };
-    }
+    return promise;
   }
 
-  return;
-};
+  handleRetry(method, args) {
+    if (!this.enabled) {
+      return this.restClient[method](...args);
+    }
 
-RetryRestClient.prototype.retryWithImmediate = function(operation, err, reject) {
-  if (operation.retry(err)) {
-    return;
+    return new Promise((resolve, reject) => {
+      const operation = retry.operation(this.retryOptions);
+
+      operation.attempt(() => {
+        this.restClient[method](...args)
+          .then((body) => {
+            resolve(body);
+          })
+          .catch((err) => {
+            if (err && err.statusCode === 429 && operation.retry(err)) {
+              return;
+            }
+            reject(err);
+          });
+      });
+    });
   }
-  reject(err);
-};
-
-RetryRestClient.prototype.retryWithDelay = function(delay, operation, err, reject) {
-  setTimeout(() => {
-    if (operation.retry(err)) {
-      return;
-    }
-    reject(err);
-  }, delay);
-};
+}
 
 module.exports = RetryRestClient;
 
@@ -207,7 +157,7 @@

RetryRestClient.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/RolesManager.html b/docs/RolesManager.html new file mode 100644 index 000000000..a1274b049 --- /dev/null +++ b/docs/RolesManager.html @@ -0,0 +1,3642 @@ + + + + + + RolesManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

RolesManager

+ + + + + + + +
+ +
+ +

+ RolesManager +

+ +

The role class provides a simple abstraction for performing CRUD operations +on Auth0 RolesManager.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new RolesManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +Auth0 RolesManagers.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

addPermissions(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Add permissions in a role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params.id + + +string + + + + + + + + + + +

ID of the Role.

+ +
data + + +object + + + + + + + + + + +

permissions data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permissions + + +string + + + + +

Array of permissions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permission_name + + +string + + + + +

Name of a permission

+ +
resource_server_identifier + + +string + + + + +

Identifier for a resource

+ +
+ + +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ROLE_ID'};
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.roles.addPermissions(params, data, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // permissions added.
+});
+ +
+ +
+ + +
+ + + +

assignUsers(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Assign users to a role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params.id + + +string + + + + + + + + + + +

ID of the Role.

+ +
data + + +object + + + + + + + + + + +

permissions data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permissions + + +string + + + + +

Array of permissions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permission_name + + +string + + + + +

Name of a permission

+ +
resource_server_identifier + + +string + + + + +

Identifier for a resource

+ +
+ + +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ROLE_ID'};
+var data = { "users" : ["userId1","userId2"]};
+
+management.roles.assignUsers(params, data, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // permissions added.
+});
+ +
+ +
+ + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new role.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Role data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.roles.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Role created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing role.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Role parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Role ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.roles.delete({ id: ROLE_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Role deleted.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 role.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Role parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Role ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.roles.get({ id: ROLE_ID }, function (err, role) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(role);
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all roles.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Roles parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.roles.getAll(params, function (err, roles) {
+  console.log(roles.length);
+});
+ +
+ +
+ + +
+ + + +

getPermissions(params, callback, emailopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Permissions in a Role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + + + + + + + + + +
callback + + + + + + + + + + +
email + + +string + + + + + + <optional>
+ + + + + +
+

Email address of user(s) to find

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +
var params = {id : 'ROLE_ID'}
+ +

+ This method takes a first argument as the roleId and returns the permissions within that role +

+ +
management.roles.getPermissions( {id : 'ROLE_ID'}, function (err, permissions) {
+  console.log(permissions);
+});
+ +
+ +
+ + +
+ + + +

getUsers(roleIdopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get Users in a Role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
roleId + + +string + + + + + + <optional>
+ + + + + +
+

Id of the role

+ +
params.per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
params.page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
params.from + + +string + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, the Id from which to start selection from.

+ +
params.take + + +number + + + + + + <optional>
+ + + + + +
+

For checkpoint pagination, the number of entries to retrieve. Default 50.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Examples
+ +
var params = {
+  roleId: 'ROLE_ID',
+  per_page: 50,
+  page: 0
+};
+ +

+ This method takes a roleId and returns all users within that role. Supports offset (page, per_page) and checkpoint pagination (from, take). You must use checkpoint pagination to retrieve beyond the first 1000 records. +

+ +
management.roles.getUsers(params, function (err, users) {
+  console.log(users);
+});
+ +
+ +
+ + +
+ + + +

removePermissions(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Remove permissions from a role

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params.id + + +string + + + + + + + + + + +

ID of the Role.

+ +
data + + +object + + + + + + + + + + +

permissions data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permissions + + +string + + + + +

Array of permissions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
permission_name + + +string + + + + +

Name of a permission

+ +
resource_server_identifier + + +string + + + + +

Identifier for a resource

+ +
+ + +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id :'ROLE_ID'};
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.roles.removePermissions(params, data, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // permissions added.
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing role.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Role parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Role ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated role data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'New name' };
+var params = { id: ROLE_ID };
+
+// Using auth0 instance.
+management.updateRole(params, data, function (err, role) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(role.name);  // 'New name'
+});
+
+// Using the roles manager directly.
+management.roles.update(params, data, function (err, role) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(role.name);  // 'New name'
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/RulesConfigsManager.html b/docs/RulesConfigsManager.html new file mode 100644 index 000000000..81a264574 --- /dev/null +++ b/docs/RulesConfigsManager.html @@ -0,0 +1,1250 @@ + + + + + + RulesConfigsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

RulesConfigsManager

+ + + + + + + +
+ +
+ +

+ RulesConfigsManager +

+ +

The rules configs manager class provides a simple abstraction for performing CRUD operations +on Auth0 RulesConfigsManager.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new RulesConfigsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +Auth0 RulesConfigsManager.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing rules config.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule Configs parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +string + + + + +

Rule Configs key.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.rulesConfigs.delete({ key: RULE_CONFIG_KEY }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Rules Config deleted.
+});
+ +
+ +
+ + +
+ + + +

getAll(cbopt) → {Promise|undefined}

+ + + + + +
+

Get all rules configs.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.rulesConfigs.getAll(function (err, rulesConfig) {
+  console.log(rulesConfig.length);
+});
+ +
+ +
+ + +
+ + + +

set(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Set a new rules config.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule Config parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +string + + + + +

Rule Config key.

+ +
+ + +
data + + +object + + + + + + + + + + +

Rule Config Data parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +string + + + + +

Rule Config Data value.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = { key: RULE_CONFIG_KEY };
+var data =   { value: RULES_CONFIG_VALUE };
+
+management.rulesConfigs.set(params, data, function (err, rulesConfig) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Rules Config set.
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/RulesManager.html b/docs/RulesManager.html new file mode 100644 index 000000000..8d0d06626 --- /dev/null +++ b/docs/RulesManager.html @@ -0,0 +1,1843 @@ + + + + + + RulesManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

RulesManager

+ + + + + + + +
+ +
+ +

+ RulesManager +

+ +

The rule class provides a simple abstraction for performing CRUD operations +on Auth0 RulesManagers.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new RulesManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for performing CRUD operations on +Auth0 RulesManagers.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

create(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Create a new rule.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Rule data object.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.rules.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Rule created.
+});
+ +
+ +
+ + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Delete an existing rule.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Rule ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.rules.delete({ id: RULE_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Rule deleted.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get an Auth0 rule.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Rule ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.rules.get({ id: RULE_ID }, function (err, rule) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(rule);
+});
+ +
+ +
+ + +
+ + + +

getAll(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get all rules.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + <optional>
+ + + + + +
+

Rules parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
per_page + + +number + + + + + + <optional>
+ + + + + +
+

Number of results per page.

+ +
page + + +number + + + + + + <optional>
+ + + + + +
+

Page number, zero indexed.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ This method takes an optional object as first argument that may be used to + specify pagination settings. If pagination options are not present, + the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
+
+management.rules.getAll(params, function (err, rules) {
+  console.log(rules.length);
+});
+ +
+ +
+ + +
+ + + +

update(params, data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update an existing rule.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Rule parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

Rule ID.

+ +
+ + +
data + + +object + + + + + + + + + + +

Updated rule data.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = { name: 'New name' };
+var params = { id: RULE_ID };
+
+// Using auth0 instance.
+management.updateRule(params, data, function (err, rule) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(rule.name);  // 'New name'
+});
+
+// Using the rules manager directly.
+management.rules.update(params, data, function (err, rule) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(rule.name);  // 'New name'
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/StatsManager.html b/docs/StatsManager.html new file mode 100644 index 000000000..2c9f8cbb0 --- /dev/null +++ b/docs/StatsManager.html @@ -0,0 +1,927 @@ + + + + + + StatsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

StatsManager

+ + + + + + + +
+ +
+ +

+ StatsManager +

+ +

Abstracts interaction with the stats endpoint.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new StatsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Stats endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

getActiveUsersCount(cbopt) → {Promise|undefined}

+ + + + + +
+

Get a the active users count.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.stats.getActiveUsersCount(function (err, usersCount) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(usersCount);
+});
+ +
+ +
+ + +
+ + + +

getDaily(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the daily stats.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

Stats parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
from + + +string + + + + +

The first day in YYYYMMDD format.

+ +
to + + +string + + + + +

The last day in YYYYMMDD format.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  from: '{YYYYMMDD}',  // First day included in the stats.
+  to: '{YYYYMMDD}'  // Last day included in the stats.
+};
+
+management.stats.getDaily(params, function (err, stats) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(stats);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/TenantManager.html b/docs/TenantManager.html new file mode 100644 index 000000000..36f50a1b9 --- /dev/null +++ b/docs/TenantManager.html @@ -0,0 +1,879 @@ + + + + + + TenantManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

TenantManager

+ + + + + + + +
+ +
+ +

+ TenantManager +

+ +

Abstracts interaction with the tenant endpoint.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new TenantManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Stats endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

getSettings(dataopt, cbopt) → {Promise|undefined}

+ + + + + +
+

Get the tenant settings..

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + <optional>
+ + + + + +
+

Request parameters

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.tenant.getSettings({ include_fields: true, fields: 'friendly_name' }, function (err, settings) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(settings);
+});
+ +
+ +
+ + +
+ + + +

updateSettings(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Update the tenant settings.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

The new tenant settings.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.tenant.updateSettings(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/TicketsManager.html b/docs/TicketsManager.html new file mode 100644 index 000000000..bb8bf298d --- /dev/null +++ b/docs/TicketsManager.html @@ -0,0 +1,1586 @@ + + + + + + TicketsManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

TicketsManager

+ + + + + + + +
+ +
+ +

+ TicketsManager +

+ +

Abstracts interaction with the tickets endpoint.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new TicketsManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +

Members

+ + + +
+

resource :external:RestClient

+ + + + +
+

Provides an abstraction layer for consuming the +Tickets endpoint.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
Type:
+ + + + + + +
+ + + + + +

Methods

+ + + +
+ + + +

changePassword(data, cbopt) → {Promise}

+ + + + + +
+

Create a new password change ticket.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
result_url + + +string + + + + + + <optional>
+ + + + + +
+

URL the user will be redirected to once ticket is used.

+ +
user_id + + +string + + + + + + <optional>
+ + + + + +
+

user_id for whom the ticket should be created. (Conflicts with: connection_id, email)

+ +
client_id + + +string + + + + + + <optional>
+ + + + + +
+

ID of the client.

+ +
organization_id + + +string + + + + + + <optional>
+ + + + + +
+

ID of the organization.

+ +
connection_id + + +string + + + + + + <optional>
+ + + + + +
+

ID of the connection.

+ +
ttl_sec + + +Integer + + + + + + <optional>
+ + + + + +
+

Number of seconds for which the ticket is valid before expiration.

+ +
email + + +string + + + + + + <optional>
+ + + + + +
+

Email of the user. (Requires: connection_id)

+ +
mark_email_as_verified + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to set the email_verified attribute to true (true) or whether it should not be updated (false).

+ +
includeEmailInRedirect + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise + + +
+
+ + + +
+ + + +
+
Example
+ +
var params = {
+  result_url: '{REDIRECT_URL}',  // Redirect after using the ticket.
+  user_id: '{USER_ID}',  // Optional.
+  email: '{USER_EMAIL}',  // Optional.
+  new_password: '{PASSWORD}'
+};
+
+management.tickets.changePassword(params, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + +
+ + + +

verifyEmail(data, cbopt) → {Promise}

+ + + + + +
+

Create an email verification ticket.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
result_url + + +string + + + + + + <optional>
+ + + + + +
+

URL the user will be redirected to once ticket is used.

+ +
user_id + + +string + + + + + + + + + + +

user_id for whom the ticket should be created.

+ +
ttl_sec + + +Integer + + + + + + <optional>
+ + + + + +
+

Number of seconds for which the ticket is valid before expiration.

+ +
includeEmailInRedirect + + +boolean + + + + + + <optional>
+ + + + + +
+

Whether to include the email address as part of the result_url (true), or not (false).

+ +
identity + + +object + + + + + + <optional>
+ + + + + +
+

Used to verify secondary, federated, and passwordless-email identities.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
user_id + + +string + + + + +

user_id of the identity.

+ +
provider + + +string + + + + +

provider of the identity.

+ +
+ + +
client_id + + +string + + + + + + <optional>
+ + + + + +
+

client ID.

+ +
organization_id + + +string + + + + + + <optional>
+ + + + + +
+

organization ID.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise + + +
+
+ + + +
+ + + +
+
Example
+ +
var data = {
+  user_id: '{USER_ID}',
+  result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
+};
+
+management.tickets.verifyEmail(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/TokensManager.html b/docs/TokensManager.html new file mode 100644 index 000000000..25e5b09c0 --- /dev/null +++ b/docs/TokensManager.html @@ -0,0 +1,1375 @@ + + + + + + TokensManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

TokensManager

+ + + + + + + +
+ +
+ +

+ TokensManager +

+ +

Provides methods for getting token data and exchanging tokens.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new TokensManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

Manager options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The auth0 account URL.

+ +
headers + + +string + + + + + + <optional>
+ + + + + +
+

Default request headers.

+ +
clientId + + +string + + + + + + <optional>
+ + + + + +
+

Default client ID.

+ +
clientSecret + + +string + + + + + + <optional>
+ + + + + +
+

Default client Secret.

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

getDelegationToken(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Exchange the token of the logged in user with a token that is valid to call +the API (signed with the API secret).

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Token data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id_token + + +string + + + + +

User ID token.

+ +
refresh_token + + +string + + + + +

User refresh token.

+ +
target + + +string + + + + +

Target client ID.

+ +
api_type + + +string + + + + +

The API to be used (aws, auth0, etc).

+ +
grant_type + + +string + + + + +

Grant type (password, jwt, etc).

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given an existing token, this endpoint will generate a new token signed + with the target client secret. This is used to flow the identity of the + user from the application to an API or across different APIs that are + protected with different secrets. Find more information in the + API Docs. +

+ +
var data = {
+  id_token: '{ID_TOKEN}',
+  api_type: 'app',
+  target: '{TARGET}',
+  grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer'
+};
+
+auth0.tokens.getDelegationToken(data, function (err, token) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(token);
+});
+ +
+ +
+ + +
+ + + +

getInfo(idToken, cbopt) → {Promise|undefined}

+ + + + + +
+

Given an ID token get the user profile linked to it.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
idToken + + +string + + + + + + + + + + +

User ID token.

+ +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Method callback.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Validates a JSON Web Token (signature and expiration) and returns the user + information associated with the user id (sub property) of the token. Find + more information in the + API Docs. +

+ +
auth0.tokens.getInfo(token, function (err, tokenInfo) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(tokenInfo);
+});
+ +
+ +
+ + +
+ + + +

revokeRefreshToken(data, cbopt) → {Promise|undefined}

+ + + + + +
+

Proactively revoke an issued refresh token.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
data + + +object + + + + + + + + + + +

Token data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
token + + +string + + + + + + + + + + +

User refresh token.

+ +
client_id + + +string + + + + + + <optional>
+ + + + + +
+

Target client ID.

+ +
client_secret + + +string + + + + + + <optional>
+ + + + + +
+

Target client secret.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function.

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +

+ Given an existing refresh token, this endpoint will revoke it in order + to prevent unauthorized silently user authentication tokens refresh. + Find more information in the API Docs. +

+ +
 var data = {
+  token: '{REFRESH_TOKEN}'
+};
+
+auth0.tokens.revokeRefreshToken(data, function (err, _) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Do stuff.
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/UserBlocksManager.html b/docs/UserBlocksManager.html new file mode 100644 index 000000000..8e6b6e87c --- /dev/null +++ b/docs/UserBlocksManager.html @@ -0,0 +1,1440 @@ + + + + + + UserBlocksManager - Documentation + + + + + + + + + + + + + + + + + +
+ +

UserBlocksManager

+ + + + + + + +
+ +
+ +

+ UserBlocksManager +

+ +

Abstracts interaction with the user-blocks endpoint.

+ + +
+ +
+
+ + +
+ + +

Constructor

+ + +

new UserBlocksManager(options)

+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
options + + +object + + + + +

The client options.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
baseUrl + + +string + + + + + + + + + + +

The URL of the API.

+ +
headers + + +object + + + + + + <optional>
+ + + + + +
+

Headers to be included in all requests.

+ +
retry + + +object + + + + + + <optional>
+ + + + + +
+

Retry Policy Config

+ +
+ + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

delete(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Unblock an user by its id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.userBlocks.delete({ id: USER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User unblocked.
+});
+ +
+ +
+ + +
+ + + +

deleteByIdentifier(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Unblock an user by identifier.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
identifier + + +string + + + + +

The user identifier, any of: username, phone_number, email.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.userBlocks.deleteByIdentifier({ identifier: USER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
+
+  // User unblocked.
+});
+ +
+ +
+ + +
+ + + +

get(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get user blocks by id.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.userBlocks.get({ id: USER_ID }, function (err, blocks) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(blocks);
+});
+ +
+ +
+ + +
+ + + +

getByIdentifier(params, cbopt) → {Promise|undefined}

+ + + + + +
+

Get user blocks by identifier.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
params + + +object + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
identifier + + +string + + + + +

The user identifier, any of: username, phone_number, email.

+ +
+ + +
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
management.userBlocks.getByIdentifier({ identifier: USER_ID }, function (err, blocks) {
+  if (err) {
+    // Handle error.
+  }
+
+  console.log(blocks);
+});
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/module-management.ManagementClient.html b/docs/UsersManager.html similarity index 60% rename from docs/module-management.ManagementClient.html rename to docs/UsersManager.html index bc804d928..f5a3e3ebb 100644 --- a/docs/module-management.ManagementClient.html +++ b/docs/UsersManager.html @@ -3,7 +3,7 @@ - ManagementClient - Documentation + UsersManager - Documentation @@ -24,12 +24,13 @@
-

ManagementClient

+

UsersManager

@@ -42,17 +43,10 @@

ManagementClient

- management. - - ManagementClient + UsersManager

-

ManagementClient -Management API SDK.

-

The Auth0 Management API is meant to be used by back-end servers or trusted -parties performing administrative tasks. Generally speaking, anything that -can be done through the Auth0 dashboard (and more) can also be done through -this API.

+

Provides methods for getting user information and impersonating users.

@@ -67,7 +61,7 @@

Constructor

-

new ManagementClient(options)

+

new UsersManager(options)

@@ -106,7 +100,7 @@

new M
Source:
@@ -156,7 +150,7 @@

Parameters:
-Object +object @@ -167,9 +161,7 @@
Parameters:
-

Options for the ManagementClient SDK. - If a token is provided only the domain is required, other parameters are ignored. - If no token is provided domain, clientId, clientSecret and scopes are required

+

Manager options.

@@ -187,8 +179,6 @@
Parameters:
- Default - Description @@ -199,13 +189,13 @@
Parameters:
- domain + baseUrl -String +string @@ -222,13 +212,9 @@
Parameters:
- - - - -

ManagementClient server domain.

+

The auth0 account URL.

@@ -237,13 +223,13 @@
Parameters:
- token + headers -String +string @@ -262,13 +248,9 @@
Parameters:
- - - - -

API access token.

+

Default request headers.

@@ -283,7 +265,7 @@
Parameters:
-String +string @@ -302,411 +284,160 @@
Parameters:
- - - - -

Management API Non Interactive Client Id.

+

Default client ID.

+ + - - - clientSecret - - - - -String - - - + - - - - <optional>
- + + + - - - - - - - - - - -

Management API Non Interactive Client Secret.

- - - - - - - audience - - - - -String - - - - - - <optional>
- - - - - - - - - - - -

Management API Audience. By default is your domain's, e.g. the domain is tenant.auth0.com and the audience is http://tenant.auth0.com/api/v2/

- - - + +
+
- - - scope - + - - - -String + + - - + - - - - <optional>
- + - + +

Members

- - + +
+

enrollments :external:RestClient

- - - - - - -

Management API Scopes.

- - - - - - - tokenProvider.enableCache - +
+

Provides an abstraction layer for retrieving Guardian enrollments.

+
- - - -Boolean - - - - - - <optional>
- - +
- - - + - - - - true - - - + - -

Enabled or Disable Cache.

- - - + - - - tokenProvider.cacheTTLInSeconds - + - - - -Number + + - - + - - - - <optional>
- + - + - - - + - - - - - + - -

By default the expires_in value will be used to determine the cached time of the token, this can be overridden.

- - - + +
Source:
+
+ - - - retry.enabled - + - - - -Boolean + +
- - +
Type:
+ - - - - true - - - - -

Enabled or Disable Retry Policy functionality.

- - - - - - - retry.maxRetries - - +
+ + - -Number +
+

identities :external:RestClient

- - - - - - <optional>
- - +
+

Provides a simple abstraction layer for linking user accounts.

+
- - - - - - - 10 - - - - -

Retry failed requests X times.

- - - - - - - - - +
- - + + + + - - - - - - - - - - - -
-
Examples
- -

- Initialize your client class with an API v2 token (you can generate one - here) and a domain. -

- -
var ManagementClient = require('auth0').ManagementClient;
-var auth0 = new ManagementClient({
-  domain: '{YOUR_ACCOUNT}.auth0.com',
-  token: '{YOUR_API_V2_TOKEN}'
-});
- -

- Initialize your client class, by using a Non Interactive Client to fetch an access_token - via the Client Credentials Grant. -

- -
var ManagementClient = require('auth0').ManagementClient;
-var auth0 = new ManagementClient({
-  domain: '{YOUR_ACCOUNT}.auth0.com',
-  clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',
-  clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}',
-  scope: "read:users write:users",
-  audience: 'https://{YOUR_TENANT_NAME}.auth0.com/api/v2/',
-  tokenProvider: {
-   enableCache: true,
-   cacheTTLInSeconds: 10
- }
-});
- -
- -
- - - - - - - - - - - - - - -

Members

- - - -
-

blacklistedTokens :BlacklistedtokensManager

- - - - -
-

Simple abstraction for performing CRUD operations on the -blacklisted tokens endpoint.

-
- - - - - -
- - - - - - - - - - - - + @@ -723,7 +454,7 @@

blac
Source:
@@ -740,7 +471,7 @@

Type:
  • -BlacklistedtokensManager +external:RestClient
  • @@ -755,14 +486,13 @@
    Type:
    -

    clientGrants :ClientGrantsManager

    +

    invalidateRememberBrowsers :external:RestClient

    -

    Simple abstraction for performing CRUD operations on the client grants -endpoint.

    +

    Provides an abstraction layer for invalidating all remembered browsers for MFA.

    @@ -798,7 +528,7 @@

    clientGra
    Source:
    @@ -815,7 +545,7 @@

    Type:
    • -ClientGrantsManager +external:RestClient
    • @@ -830,14 +560,14 @@
      Type:
      -

      clients :ClientsManager

      +

      multifactor :external:RestClient

      -

      Simple abstraction for performing CRUD operations on the -clients endpoint.

      +

      Provides an abstraction layer for consuming the +Multifactor Provider endpoint.

      @@ -873,7 +603,7 @@

      clientsSource:
      @@ -890,7 +620,7 @@
      Type:
      • -ClientsManager +external:RestClient
      • @@ -905,14 +635,13 @@
        Type:
        -

        connections :ConnectionsManager

        +

        permissions :external:RestClient

        -

        Simple abstraction for performing CRUD operations on the -connections endpoint.

        +

        Provides an abstraction layer for CRD on permissions directly on a user

        @@ -948,7 +677,7 @@

        connection
        Source:
        @@ -965,7 +694,7 @@

        Type:
        • -ConnectionsManager +external:RestClient
        • @@ -980,14 +709,13 @@
          Type:
          -

          customDomains :CustomDomainsManager

          +

          recoveryCodeRegenerations :external:RestClient

          -

          Simple abstraction for performing CRUD operations on the -custom domains endpoint.

          +

          Provides an abstraction layer for regenerating Guardian recovery codes.

          @@ -1023,7 +751,7 @@

          customDo
          Source:
          @@ -1040,7 +768,7 @@

          Type:
          • -CustomDomainsManager +external:RestClient
          • @@ -1055,14 +783,13 @@
            Type:
            -

            deviceCredentials :DeviceCredentialsManager

            +

            roles :external:RestClient

            -

            Simple abstraction for performing CRUD operations on the -device credentials endpoint.

            +

            Provides an abstraction layer for CRD on roles for a user

            @@ -1098,7 +825,7 @@

            devi
            Source:
            @@ -1115,7 +842,7 @@

            Type:
            • -DeviceCredentialsManager +external:RestClient
            • @@ -1130,14 +857,13 @@
              Type:
              -

              emailProvider :EmailProviderManager

              +

              userLogs :external:RestClient

              -

              Simple abstraction for performing CRUD operations on the -email provider endpoint.

              +

              Provides a simple abstraction layer for user logs

              @@ -1173,7 +899,7 @@

              emailPro
              Source:
              @@ -1190,7 +916,7 @@

              Type:
              • -EmailProviderManager +external:RestClient
              • @@ -1205,14 +931,13 @@
                Type:
                -

                emailTemplates :EmailTemplatesManager

                +

                usersByEmail :external:RestClient

                -

                Simple abstraction for performing CRUD operations on -Auth0's Email Templates

                +

                Provides an abstraction layer for the new "users-by-email" API

                @@ -1248,7 +973,7 @@

                emailTe
                Source:
                @@ -1265,7 +990,7 @@

                Type:
                + + + +

                Methods

                + + -
                -

                guardian :GuardianManager

                +
                + + + +

                assignPermissions(params, data, cbopt) → {Promise|undefined}

                +
                -

                Simple abstraction for performing CRUD operations on the -guardian endpoint.

                +

                Assign permissions to a user

                @@ -1323,7 +1057,7 @@

                guardianSource:
                @@ -1336,256 +1070,315 @@

                guardianType:

                -
                  -
                • - -GuardianManager -
                • -
                +
                Parameters:
                + -

                + + + + + + + + - -
                -

                jobs :JobsManager

                +
                + + + + + + + -
                -

                Jobs manager.

                -
                + + + + + + + + - + - + + + -
                Type:
                -
                  -
                • +
                + + -JobsManager - - - - + + + -
                -

                logs :LogsManager

                + +
                + - - - - - - - -
                Source:
                -
                - - - - - - - - - - - -
                Type:
                -
                  -
                • +
                + + -LogsManager - - - - - - - + + + + -
                -

                Simple abstraction for performing CRUD operations on the -resource servers endpoint.

                -
                + + + + + +
                NameTypeAttributesDescription
                params + + +object + + + -
                + - + +
                +

                params object

                + + - + + + + + + - + - + - + - + + + + - + + + + - + - + - + + + + - + +
                NameTypeDescription
                id + + +string - - -
                Source:
                -
                - + +
                +

                user_id

                + +
                + +
                data + + +string + + + - + - + + +

                data object containing list of permissions

                + + + + + + + + -
                -

                Logs manager.

                -
                + + + + + + + + -
                +
                + + + - + - + - + - + + + +
                NameTypeDescription
                permissions + + +string - - + + +

                Array of permission IDs

                + +
                - + +
                cb + + +function - - -
                -

                resourceServers :ResourceServersManager

                +
                + + <optional>
                + + + +
                +

                Callback function.

                + +
                -
                - - - - - - - - - - - +
                +
                Returns:
                - + - -
                Source:
                -
                - +
                +
                + Type: +
                +
                + +Promise +| - +undefined - - +
                - -
                Type:
                -
                  -
                • - -ResourceServersManager + +
                - -
              +
              +
              Example
              +
              var params =  { id : 'USER_ID';
              +var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
               
              +management.users.assignPermissions(params, data, function (err, user) {
              +  if (err) {
              +    // Handle error.
              +  }
               
              +  // permissions added.
              +});
              +
              -
              -

              rules :RulesManager

              +
              + + +

              assignRoles(params, data, cbopt) → {Promise|undefined}

              + +
              -

              Simple abstraction for performing CRUD operations on the -rules endpoint.

              +

              Assign roles to a user

              @@ -1621,7 +1414,7 @@

              rulesSource:
              @@ -1634,180 +1427,315 @@

              rulesType:

              -
                -
              • - -RulesManager -
              • -
              +
              Parameters:
              + -

              + + + + + + + + + + + + + + + + + + + + + + + -
              -

              rulesConfigs :RulesConfigsManager

              +
              -
              -

              RulesConfigs manager.

              -
              + + + + + + - - + + + + + + + + + + + - + + + + - + - + + + - + - -
              Source:
              -
              - + + + +
              NameTypeAttributesDescription
              params + + +object + + + + + + +

              params object

              + + -
              + + + + + + - + - + - + - + + + + - + + + + - + - + - + - + + -
              Source:
              -
              - + +
              NameTypeDescription
              id + + +string - - + + +

              user_id

              + +
              - + +
              data + + +string -
              Type:
              -
                -
              • -RulesConfigsManager +
              + - - + + + +

              data object containing list of role IDs

              + + + + + + + + - + - -
              -

              stats :StatsManager

              + +
              + + + + -
              -

              ManagementClient account statistics manager.

              -
              + + + + + + -
              + - +
              + + +
              NameTypeDescription
              roles + + +string + + +

              Array of role IDs

              + +
              - + +
              cb + + +function - - + + + + <optional>
              + - + - + +
              +

              Callback function.

              + +
              - - -

-
Type:
- + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
+ + + +
+
Example
+ +
var params =  { id : 'USER_ID';
+var data = { "roles" : ["roleId1", "roleID2"]};
+
+management.users.assignRoles(params, data, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // roles added.
+});
+
+
-
-

tenant :TenantManager

+
+ + + +

create(data, cbopt) → {Promise|undefined}

+
-

ManagementClient tenant settings manager.

+

Create a new user.

@@ -1843,7 +1771,7 @@

tenantSource:
@@ -1856,191 +1784,176 @@

tenantType:

-
    -
  • - -TenantManager - -
  • -
-

+
Parameters:
+ + + + + + - -
-

tickets :TicketsManager

+
+ + + + -
-

Tickets manager.

-
+ + + + + + + + + + - + + + - + - + + - + + + + - + - + + + - + - + + - + +
NameTypeAttributesDescription
data + + +object -
+ +
+ - + - + + +

User data.

+ +
cb + + +function - - + + + + <optional>
+ - + - -
Source:
-
- + +
+

Callback function.

+ +
-
Type:
- -
- - -
-

users :UsersManager

+
+
Returns:
-
-

Simple abstraction for performing CRUD operations on the -users endpoint.

-
+ +
+
+ Type: +
+
+ +Promise +| +undefined +
+
-
+
- - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - - - - - -
Type:
- +
+
Example
+
management.users.create(data, function (err) {
+  if (err) {
+    // Handle error.
+  }
 
+  // User created.
+});
- - - - -

Methods

- +
-

blacklistToken(token, cbopt) → {Promise|undefined}

+

delete(params, cbopt) → {Promise|undefined}

-

Blacklist a new token.

+

Delete a user by its id.

@@ -2076,7 +1989,7 @@

blackli
Source:
@@ -2122,13 +2035,13 @@

Parameters:
- token + params -Object +object @@ -2147,7 +2060,7 @@
Parameters:
-

Token data.

+

The user data object..

@@ -2173,39 +2086,13 @@
Parameters:
- aud - - - - - -String - - - - - - - - - - -

Audience (your app client ID).

- - - - - - - - - jti + id -String +string @@ -2216,7 +2103,7 @@
Parameters:
-

The JWT ID claim.

+

The user id.

@@ -2260,7 +2147,7 @@
Parameters:
-

Callback function.

+

Callback function

@@ -2311,17 +2198,12 @@
Returns:
Example
-
var token = {
- aud: 'aud',
- jti: 'jti'
-};
-
-management.blacklistToken(token, function (err) {
+    
management.users.delete({ id: USER_ID }, function (err) {
   if (err) {
     // Handle error.
   }
 
-  // Token blacklisted.
+  // User deleted.
 });
@@ -2333,14 +2215,14 @@
Example
-

configureEmailProvider(data, cbopt) → {Promise|undefined}

+

deleteAll(cbopt) → {Promise|undefined}

-

Configure the email provider.

+

Delete all users.

@@ -2364,6 +2246,8 @@

Deprecated:
  • This method will be removed in the next major release.
+ @@ -2376,7 +2260,7 @@

Source:
@@ -2420,40 +2304,6 @@

Parameters:
- - - data - - - - - -Object - - - - - - - - - - - - - - - - - - -

The email provider data object.

- - - - - - cb @@ -2483,7 +2333,7 @@
Parameters:
-

Callback function.

+

Callback function

@@ -2534,12 +2384,12 @@
Returns:
Example
-
management.configureEmailProvider(data, function (err) {
+    
management.users.deleteAll(function (err) {
   if (err) {
     // Handle error.
   }
 
-  // Email provider configured.
+  // Users deleted
 });
@@ -2551,14 +2401,14 @@
Example
-

createClient(data, cbopt) → {Promise|undefined}

+

deleteMultifactorProvider(params, cbopt) → {Promise|undefined}

-

Create an Auth0 client.

+

Delete a multifactor provider.

@@ -2594,7 +2444,7 @@

createCli
Source:
@@ -2640,13 +2490,13 @@

Parameters:
- data + params -Object +object @@ -2665,7 +2515,84 @@
Parameters:
-

The client data object.

+

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
provider + + +string + + + + +

Multifactor provider.

+ +
+ @@ -2701,7 +2628,7 @@
Parameters:
-

Callback function.

+

Callback function

@@ -2752,12 +2679,14 @@
Returns:
Example
-
management.createClient(data, function (err) {
+    
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
+
+management.users.deleteMultifactorProvider(params, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  // Client created.
+  // Users accounts unlinked.
 });
@@ -2769,14 +2698,14 @@
Example
-

createConnection(data, cbopt) → {Promise|undefined}

+

get(data, cbopt) → {Promise|undefined}

-

Create a new connection.

+

Get a user by its id.

@@ -2812,7 +2741,7 @@

creat
Source:
@@ -2864,7 +2793,7 @@

Parameters:
-Object +object @@ -2883,43 +2812,50 @@
Parameters:
-

Connection data object.

+

The user data object.

- - + + + + + + + + + + + + + + + + + + + - + - - @@ -2928,6 +2864,52 @@
Parameters:
NameTypeDescription
cbid -function +string - - <optional>
- - - - - -
-

Callback function.

+

The user id.

+ + + + + + + + + cb + + + + + +function + + + + + + + + + <optional>
+ + + + + + + + + + + +

Callback function.

+ + + + + + + + + + @@ -2939,8 +2921,6 @@
Parameters:
- -
Returns:
@@ -2970,12 +2950,8 @@
Returns:
Example
-
management.createConnection(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Conection created.
+    
management.users.get({ id: USER_ID }, function (err, user) {
+  console.log(user);
 });
@@ -2987,14 +2963,14 @@
Example
-

createDevicePublicKey(data, cbopt) → {Promise|undefined}

+

getAll(paramsopt, cbopt) → {Promise|undefined}

-

Create an Auth0 credential.

+

Get all users.

@@ -3030,7 +3006,7 @@

Source:
@@ -3076,13 +3052,13 @@

Parameters:
- data + params -Object +object @@ -3091,6 +3067,8 @@
Parameters:
+ <optional>
+ @@ -3101,22 +3079,41 @@
Parameters:
-

The device credential data object.

+

Users params.

- - + + + + + + + + + + + + + + + + + + + + + - + - -
NameTypeAttributesDescription
cbper_page -function +number @@ -3137,159 +3134,55 @@
Parameters:
-

Callback function.

+

Number of results per page.

- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.createConnection(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Credential created.
-});
- -
-
- + + + page -
- - - -

createEmailVerificationTicket(cbopt) → {Promise}

- - - - - -
-

Create an email verification ticket.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
+ + + +number + + + + + + <optional>
+ + + + + + + +

Page number, zero indexed.

+ + + -
Parameters:
+ + - - - - - - - - - - - - - - - - - - + + + - @@ -3355,6 +3248,9 @@
Returns:
Promise +| + +undefined
@@ -3369,15 +3265,20 @@
Returns:
Example
-
var data = {
-  user_id: '{USER_ID}',
-  result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
+        

+ This method takes an optional object as first argument that may be used to + specify pagination settings and the search query. If pagination options are + not present, the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
 };
 
-auth0.createEmailVerificationTicket(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
+management.users.getAll(params, function (err, users) {
+  console.log(users.length);
 });
@@ -3389,14 +3290,14 @@
Example
-

createPasswordChangeTicket(cbopt) → {Promise}

+

getByEmail(emailopt, optionsopt, cbopt) → {Promise|undefined}

-

Create a new password change ticket.

+

Get Users by an Email Address

@@ -3432,7 +3333,7 @@

Source:
@@ -3478,13 +3379,13 @@
Parameters:

- + - -
NameTypeAttributesDescription
cbemail -function +string @@ -3505,140 +3406,45 @@
Parameters:
-

Callback function.

+

Email address of user(s) to find

- - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise - - -
-
- - - -
- - - -
-
Example
- -
var params = {
-  result_url: '{REDIRECT_URL}',  // Redirect after using the ticket.
-  user_id: '{USER_ID}',  // Optional.
-  email: '{USER_EMAIL}',  // Optional.
-  new_password: '{PASSWORD}'
-};
-
-auth0.createPasswordChangeTicket(params, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -
- -
- + + + options -
- - - -

createResourceServer(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create a new resource server.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- + + + +object + + + + + + <optional>
+ + + + + + -
Parameters:
- + +

Additional options to pass to the endpoint

+ + @@ -3664,13 +3470,49 @@
Parameters:
- + + + + + + + + + + + + + + + + + + + + + + + +
datafields + + +string + + + + + + <optional>
+ + + + + +
+

Comma-separated list of fields to include or exclude in the result

+ +
include_fields -Object +boolean @@ -3679,6 +3521,8 @@
Parameters:
+ <optional>
+ @@ -3689,7 +3533,15 @@
Parameters:
-

Resource Server data object.

+

Whether specified fields are to be included (true) or excluded (false). Defaults to true.

+ +
+ @@ -3776,12 +3628,13 @@
Returns:
Example
-
management.createResourceServer(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Resource Server created.
+        

+ This method takes a first argument as the Email address to look for + users, and uses the /users-by-email API, not the search API +

+ +
management.users.getByEmail('email@address', function (err, users) {
+  console.log(users);
 });
@@ -3793,14 +3646,14 @@
Example
-

createRule(data, cbopt) → {Promise|undefined}

+

getGuardianEnrollments(data, cbopt) → {Promise|undefined}

-

Create a new rule.

+

Get a list of Guardian enrollments.

@@ -3836,7 +3689,7 @@

createRule<
Source:
@@ -3888,7 +3741,7 @@

Parameters:
-Object +object @@ -3907,7 +3760,58 @@
Parameters:
-

Rule data object.

+

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ @@ -3994,12 +3898,8 @@
Returns:
Example
-
management.createRule(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Rule created.
+    
management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
+  console.log(enrollments);
 });
@@ -4011,14 +3911,14 @@
Example
-

createUser(data, cbopt) → {Promise|undefined}

+

getInfo(accessToken, cbopt) → {Promise|undefined}

-

Create a new user.

+

Given an access token get the user profile linked to it.

@@ -4054,7 +3954,7 @@

createUser<
Source:
@@ -4100,13 +4000,13 @@

Parameters:
- data + accessToken -Object +string @@ -4125,7 +4025,7 @@
Parameters:
-

User data.

+

User access token.

@@ -4212,12 +4112,18 @@
Returns:
Example
-
management.createUser(data, function (err) {
+        

+ Get the user information based on the Auth0 access token (obtained during + login). Find more information in the + API Docs. +

+ +
auth0.users.getInfo(accessToken, function (err, userInfo) {
   if (err) {
     // Handle error.
   }
 
-  // User created.
+  console.log(userInfo);
 });
@@ -4229,14 +4135,14 @@
Example
-

deleteAllUsers(cbopt) → {Promise|undefined}

+

getPermissions(data, cbopt) → {Promise|undefined}

-

Delete all users.

+

Get a list of permissions for a user.

@@ -4260,8 +4166,6 @@

deleteA -
Deprecated:
  • This method will be removed in the next major release.
- @@ -4274,7 +4178,7 @@

deleteA
Source:
@@ -4320,13 +4224,13 @@

Parameters:
- cb + data -function +object @@ -4335,8 +4239,6 @@
Parameters:
- <optional>
- @@ -4347,7 +4249,94 @@
Parameters:
-

Callback function

+

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + + + + + + + + + cb + + + + + +function + + + + + + + + + <optional>
+ + + + + + + + + + + +

Callback function.

@@ -4398,12 +4387,8 @@
Returns:
Example
-
management.deleteAllUsers(function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Users deleted
+    
management.users.getPermissions({ id: USER_ID }, function (err, permissions) {
+  console.log(permissions);
 });
@@ -4415,14 +4400,14 @@
Example
-

deleteClient(params, cbopt) → {Promise|undefined}

+

getRoles(data, cbopt) → {Promise|undefined}

-

Delete an Auth0 client.

+

Get a list of roles for a user.

@@ -4458,7 +4443,7 @@

deleteCli
Source:
@@ -4504,13 +4489,13 @@

Parameters:
- params + data -Object +object @@ -4529,7 +4514,7 @@
Parameters:
-

Client parameters.

+

The user data object.

@@ -4555,13 +4540,13 @@
Parameters:
- client_id + id -String +string @@ -4572,7 +4557,7 @@
Parameters:
-

Application client ID.

+

The user id.

@@ -4667,12 +4652,8 @@
Returns:
Example
-
management.deleteClient({ client_id: CLIENT_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Client deleted.
+    
management.users.getRoles({ id: USER_ID }, function (err, roles) {
+  console.log(roles);
 });
@@ -4684,14 +4665,14 @@
Example
-

deleteConnection(params, cbopt) → {Promise|undefined}

+

getUserOrganizations(data, cbopt) → {Promise|undefined}

-

Delete an existing connection.

+

Get a list of organizations for a user.

@@ -4727,7 +4708,7 @@

delet
Source:
@@ -4773,13 +4754,13 @@

Parameters:
- params + data -Object +object @@ -4798,7 +4779,7 @@
Parameters:
-

Connection parameters.

+

The user data object.

@@ -4830,7 +4811,7 @@
Parameters:
-String +string @@ -4841,7 +4822,7 @@
Parameters:
-

Connection ID.

+

The user id.

@@ -4936,12 +4917,8 @@
Returns:
Example
-
management.deleteConnection({ id: CONNECTION_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Conection deleted.
+    
management.users.getUserOrganizations({ id: USER_ID }, function (err, orgs) {
+  console.log(orgs);
 });
@@ -4953,14 +4930,14 @@
Example
-

deleteDeviceCredential(params, cbopt) → {Promise|undefined}

+

impersonate(userId, settings, cbopt) → {Promise|undefined}

-

Delete an Auth0 device credential.

+

Impersonate the user with the given user ID.

@@ -4996,7 +4973,7 @@

Source:
@@ -5042,13 +5019,47 @@

Parameters:
- params + userId + + + + + +string + + + + + + + + + + + + + + + + + + +

User ID token.

+ + + + + + + + + settings -Object +object @@ -5067,7 +5078,7 @@
Parameters:
-

Credential parameters.

+

Impersonation settings.

@@ -5081,6 +5092,8 @@
Parameters:
Type + Attributes + @@ -5093,24 +5106,136 @@
Parameters:
- id + impersonator_id + + + + + +string + + + + + + + + + + + + + + + + + + +

Impersonator user ID.

+ + + + + + + + + protocol + + + + + +string + + + + + + + + + + + + + + + + + + +

The authentication protocol.

+ + + + + + + + + token + + + + + +string + + + + + + + + + + + + + + + + + + +

API v1 token obtained for impersonation

+ + + + + + + + + clientId -String +string + + + <optional>
+ + + + + + + -

Device credential ID.

+

Client id used for impersonation. Uses the one supplied in the constructor by default.

@@ -5205,14 +5330,24 @@
Returns:
Example
-
var params = { id: CREDENTIAL_ID };
+        

+ Gets a link that can be used once to log in as a specific user. Useful for + troubleshooting. Find more information in the + [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate). +

+ +
var settings = {
+  impersonator_id: '{IMPERSONATOR_ID}',
+  protocol: 'oauth2',
+  additionalParameters: {}  // Optional additional params.
+};
 
-management.deleteDeviceCredential(params, function (err) {
+auth0.users.impersonate(userId, settings, function (err, link) {
   if (err) {
     // Handle error.
   }
 
-  // Credential deleted.
+  console.log(link);
 });
@@ -5224,14 +5359,14 @@
Example
-

deleteEmailProvider(cbopt) → {Promise|undefined}

+

invalidateRememberBrowser(params, cbopt) → {Promise|undefined}

-

Delete email provider.

+

Invalidate all remembered browsers for MFA.

@@ -5267,7 +5402,7 @@

de
Source:
@@ -5313,13 +5448,98 @@

Parameters:
- cb + params -function +object + + + + + + + + + + + + + + + + + + +

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + + + + + + + + + cb + + + + + +function @@ -5391,12 +5611,12 @@
Returns:
Example
-
management.deleteEmailProvider(function (err) {
+    
management.users.invalidateRememberBrowser({ id: USER_ID }, function (err, result) {
   if (err) {
     // Handle error.
   }
 
-  // Email provider deleted.
+  // Invalidated all remembered browsers.
 });
@@ -5408,14 +5628,14 @@
Example
-

deleteGuardianEnrollment(data, cbopt) → {Promise|undefined}

+
-

Delete a user's Guardian enrollment.

+

Link the user with another account.

@@ -5451,7 +5671,7 @@

Source:
@@ -5497,13 +5717,47 @@
Parameters:
- data + userId + + + + + +string + + + + + + + + + + + + + + + + + + +

ID of the primary user.

+ + + + + + + + + params -Object +object @@ -5522,7 +5776,7 @@
Parameters:
-

The Guardian enrollment data object.

+

Secondary user data.

@@ -5548,13 +5802,91 @@
Parameters:
- id + user_id + + + + + +string + + + + + + + + + + +

ID of the user to be linked.

+ + + + + + + + + connection_id + + + + + +string + + + + + + + + + + +

ID of the connection to be used.

+ + + + + + + + + provider + + + + + +string + + + + + + + + + + +

Identity provider of the secondary user account being linked.

+ + + + + + + + + link_with -String +string @@ -5565,7 +5897,7 @@
Parameters:
-

The Guardian enrollment id.

+

JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent.

@@ -5660,12 +5992,18 @@
Returns:
Example
-
management.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err) {
+    
var userId = 'USER_ID';
+var params = {
+  user_id: 'OTHER_USER_ID',
+  connection_id: 'CONNECTION_ID'
+};
+
+management.users.link(userId, params, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  // Email provider deleted.
+  // Users linked.
 });
@@ -5677,14 +6015,14 @@
Example
-

deleteResourceServer(params, cbopt) → {Promise|undefined}

+

logs(params, cbopt) → {Promise|undefined}

-

Delete an existing resource server.

+

Get user's log events.

@@ -5720,7 +6058,7 @@

d
Source:
@@ -5772,7 +6110,7 @@

Parameters:
-Object +object @@ -5791,7 +6129,7 @@
Parameters:
-

Resource Server parameters.

+

Get logs data.

@@ -5823,7 +6161,7 @@
Parameters:
-String +string @@ -5834,15 +6172,33 @@
Parameters:
-

Resource Server ID.

+

User id.

- - + + + per_page + + + + + +number + + + + + + + + + + +

Number of results per page.

@@ -5851,42 +6207,128 @@
Parameters:
- cb + page -function +number - - - <optional>
- - - - - - - -

Callback function.

+

Page number, zero indexed.

- - - + + + + sort + + + + + +string + + + + + + + + + + +

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

+ + + + + + + + + include_totals + + + + + +boolean + + + + + + + + + + +

true if a query summary must be included in the result, false otherwise. Default false;

+ + + + + + + + + + + + + + + + + cb + + + + + +function + + + + + + + + + <optional>
+ + + + + + + + + + + +

Callback function.

+ + + + + + + + @@ -5929,12 +6371,14 @@
Returns:
Example
-
management.deleteResourceServer({ id: RESOURCE_SERVER_ID }, function (err) {
+    
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
+
+management.users.logs(params, function (err, logs) {
   if (err) {
     // Handle error.
   }
 
-  // Resource Server deleted.
+  console.log(logs);
 });
@@ -5946,14 +6390,14 @@
Example
-

deleteRule(params, cbopt) → {Promise|undefined}

+

regenerateRecoveryCode(params, cbopt) → {Promise|undefined}

-

Delete an existing rule.

+

Generate new Guardian recovery code.

@@ -5989,7 +6433,7 @@

deleteRule<
Source:
@@ -6041,7 +6485,7 @@

Parameters:
-Object +object @@ -6060,7 +6504,7 @@
Parameters:
-

Rule parameters.

+

Get logs data.

@@ -6092,7 +6536,7 @@
Parameters:
-String +string @@ -6103,7 +6547,7 @@
Parameters:
-

Rule ID.

+

User id.

@@ -6198,12 +6642,8 @@
Returns:
Example
-
auth0.deleteRule({ id: RULE_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Rule deleted.
+    
management.users.regenerateRecoveryCode("USER_ID", function (err, result) {
+  console.log(result.recovery_code);
 });
@@ -6215,14 +6655,14 @@
Example
-

deleteRulesConfig(params, cbopt) → {Promise|undefined}

+

removePermissions(params, data, cbopt) → {Promise|undefined}

-

Delete rules config.

+

Remove permissions from a user

@@ -6258,7 +6698,7 @@

dele
Source:
@@ -6310,7 +6750,92 @@

Parameters:
-Object +object + + + + + + + + + + + + + + + + + + +

params object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

user_id

+ +
+ + + + + + + + + + data + + + + + +object @@ -6329,7 +6854,7 @@
Parameters:
-

Rule Configs parameters.

+

data object containing list of permission IDs

@@ -6355,13 +6880,13 @@
Parameters:
- key + permissions -String +string @@ -6372,7 +6897,7 @@
Parameters:
-

Rule Configs key.

+

Array of permission IDs

@@ -6467,12 +6992,15 @@
Returns:
Example
-
management.deleteRulesConfig({ key: RULE_CONFIG_KEY }, function (err) {
+    
var params =  { id : 'USER_ID';
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.users.removePermissions(params, data, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  // Rules Config deleted.
+  // permissions removed.
 });
@@ -6484,14 +7012,14 @@
Example
-

deleteUser(params, cbopt) → {Promise|undefined}

+

removeRoles(params, data, cbopt) → {Promise|undefined}

-

Delete a user by its id.

+

Remove roles from a user

@@ -6527,7 +7055,7 @@

deleteUser<
Source:
@@ -6579,7 +7107,7 @@

Parameters:
-Object +object @@ -6598,7 +7126,7 @@
Parameters:
-

The user data object..

+

params object

@@ -6630,7 +7158,7 @@
Parameters:
-String +string @@ -6641,7 +7169,7 @@
Parameters:
-

The user id.

+

user_id

@@ -6658,13 +7186,13 @@
Parameters:
- cb + data -function +string @@ -6673,8 +7201,6 @@
Parameters:
- <optional>
- @@ -6685,63 +7211,153 @@
Parameters:
-

Callback function

+

data object containing list of role IDs

- - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
roles + + +string + + +

Array of role IDs

+ +
+ + + + + + + + + + cb + + + + + +function + + + + + + + + + <optional>
+ + + + + + + + + + + +

Callback function.

+ + + + + + + -
-
Returns:
- -
-
- Type: -
-
- -Promise -| -undefined -
-
- -
+ + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +Promise +| + +undefined + + +
+
+ + + +
Example
-
management.deleteUser({ id: USER_ID }, function (err) {
+    
var params =  { id : 'USER_ID';
+var data = { "roles" : ["roleId1", "roleID2"]};
+
+management.users.removeRoles(params, data, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  // User deleted.
+  // roles removed.
 });
@@ -6753,14 +7369,14 @@
Example
-

deleteUserMultifactor(params, cbopt) → {Promise|undefined}

+
-

Delete a multifactor provider for a user.

+

Unlink the given accounts.

@@ -6796,7 +7412,7 @@

Source:
@@ -6848,7 +7464,7 @@

Parameters:
-Object +object @@ -6867,7 +7483,7 @@
Parameters:
-

Data object.

+

Linked users data.

@@ -6899,7 +7515,7 @@
Parameters:
-String +string @@ -6910,7 +7526,7 @@
Parameters:
-

The user id.

+

Primary user ID.

@@ -6925,7 +7541,7 @@
Parameters:
-String +string @@ -6936,7 +7552,33 @@
Parameters:
-

Multifactor provider.

+

Identity provider in use.

+ + + + + + + + + user_id + + + + + +string + + + + + + + + + + +

Secondary user ID.

@@ -6980,7 +7622,7 @@
Parameters:
-

Callback function

+

Callback function.

@@ -7031,9 +7673,9 @@
Returns:
Example
-
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
+    
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };
 
-management.deleteUserMultifactor(params, function (err, user) {
+management.users.unlink(params, function (err, user) {
   if (err) {
     // Handle error.
   }
@@ -7050,14 +7692,14 @@ 
Example
-

deleteUserMultifcator(params, cbopt) → {Promise|undefined}

+

update(params, data, cbopt) → {Promise|undefined}

-

Delete a multifactor provider for a user.

+

Update a user by its id.

@@ -7081,10 +7723,6 @@

-
Deprecated:
  • The function name has a typo. -We're shipping this so it doesn't break compatibility. -Use deleteUserMultifactor instead.
- @@ -7097,7 +7735,7 @@

Source:
@@ -7149,7 +7787,7 @@

Parameters:
-Object +object @@ -7168,7 +7806,7 @@
Parameters:
-

Data object.

+

The user parameters.

@@ -7200,7 +7838,7 @@
Parameters:
-String +string @@ -7217,35 +7855,43 @@
Parameters:
+ + + + + + + + - provider + data -String +object + + - + - -

Multifactor provider.

- - + + - - - + + +

New user data.

@@ -7332,14 +7978,15 @@
Returns:
Example
-
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
+    
var params = { id: USER_ID };
 
-management.deleteUserMultifcator(params, function (err, user) {
+management.users.update(params, data, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  // Users accounts unlinked.
+  // Updated user.
+  console.log(user);
 });
@@ -7351,14 +7998,14 @@
Example
-

getActiveUsersCount(cbopt) → {Promise|undefined}

+

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

-

Get a the active users count.

+

Update the app metadata.

@@ -7394,7 +8041,7 @@

ge
Source:
@@ -7438,6 +8085,125 @@

Parameters:
+ + + params + + + + + +object + + + + + + + + + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + + + + + + + + + metadata + + + + + +object + + + + + + + + + + + + + + + + + + +

New app metadata.

+ + + + + + cb @@ -7467,7 +8233,7 @@
Parameters:
-

Callback function.

+

Callback function

@@ -7518,12 +8284,18 @@
Returns:
Example
-
management.getActiveUsersCount(function (err, usersCount) {
-  if (err) {
-    // Handle error.
-  }
+    
var params = { id: USER_ID };
+var metadata = {
+  foo: 'bar'
+};
+
+management.users.updateAppMetadata(params, metadata, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
 
-  console.log(usersCount);
+  // Updated user.
+  console.log(user);
 });
@@ -7535,14 +8307,14 @@
Example
-

getBlacklistedTokens(cbopt) → {Promise|undefined}

+

updateUserMetadata(params, metadata, cbopt) → {Promise|undefined}

-

Get all blacklisted tokens.

+

Update the user metadata.

@@ -7578,7 +8350,7 @@

g
Source:
@@ -7622,6 +8394,125 @@

Parameters:
+ + + params + + + + + +object + + + + + + + + + + + + + + + + + + +

The user data object..

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + + + + + + + + + metadata + + + + + +object + + + + + + + + + + + + + + + + + + +

New user metadata.

+ + + + + + cb @@ -7651,7 +8542,7 @@
Parameters:
-

Callback function.

+

Callback function

@@ -7702,28 +8593,67 @@
Returns:
Example
-
management.getBlacklistedTokens(function (err, tokens) {
-  console.log(tokens.length);
+    
var params = { id: USER_ID };
+var metadata = {
+  address: '123th Node.js Street'
+};
+
+management.users.updateUserMetadata(params, metadata, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
+
+  // Updated user.
+  console.log(user);
 });
- -
+ + + + + + + + + + + + + + +
+ +
+ +

+ UsersManager +

+ +

Abstracts interaction with the users endpoint.

+ +
-

getClient(params, cbopt) → {Promise|undefined}

+
+
+ + +
+

Constructor

+ +

new UsersManager(options)

+ + -
-

Get an Auth0 client.

-
@@ -7758,7 +8688,7 @@

getClientSource:
@@ -7790,8 +8720,6 @@
Parameters:
Type - Attributes - @@ -7804,32 +8732,24 @@
Parameters:
- params + options -Object +object - - - - - - - - -

Client parameters.

+

The client options.

@@ -7843,6 +8763,8 @@
Parameters:
Type + Attributes + @@ -7855,32 +8777,68 @@
Parameters:
- client_id + baseUrl -String +string + + + + + + + + -

Application client ID.

+

The URL of the API.

- - + + + headers + + + + + +object + + + + + + + + + <optional>
+ + + + + + + + + + + +

Headers to be included in all requests.

@@ -7889,13 +8847,13 @@
Parameters:
- cb + retry -function +object @@ -7916,7 +8874,7 @@
Parameters:
-

Callback function.

+

Retry Policy Config

@@ -7925,7 +8883,13 @@
Parameters:
+ + + + + + @@ -7938,60 +8902,37 @@
Parameters:
-
-
Returns:
- -
-
- Type: -
-
- -Promise -| -undefined +
+ +

- - + + -
+ + -
-
Example
- -
management.getClient({ client_id: CLIENT_ID }, function (err, client) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(client);
-});
- -
+ +

Members

-
-
- - - -

getClientInfo() → {Object}

+
+

enrollments :external:RestClient

-
-

Return an object with information about the current client,

+

Provides an abstraction layer for retrieving Guardian enrollments.

@@ -8027,7 +8968,7 @@

getClien
Source:
@@ -8040,66 +8981,106 @@

getClien +

Type:
+ +
+ + +
+

identities :external:RestClient

+
+

Provides a simple abstraction layer for linking user accounts.

+
+
+ + -
-
Returns:
+ - + -
-
- Type: -
-
- -Object + + -
-
+ + -
-

Object containing client information.

-
+ -
+ + -
- - -
+ +
Source:
+
+ -

getClients(paramsopt, cbopt) → {Promise|undefined}

+ + + + + +
Type:
+ + + + + + +
+ + + +
+

invalidateRememberBrowsers :external:RestClient

+
-

Get all Auth0 clients.

+

Provides an abstraction layer for invalidating all remembered browsers for MFA.

@@ -8135,7 +9116,7 @@

getClients<
Source:
@@ -8148,285 +9129,181 @@

getClients< +

Type:
+ -
Parameters:
- +
- - - - - + +
+

multifactor :external:RestClient

-
- - - - - - - +
+

Provides an abstraction layer for consuming the +Multifactor Provider endpoint.

+
- - - - - - - +
- -
- + - + - - +
+

Provides an abstraction layer for CRD on permissions directly on a user

+
- - - - - - - - - - - - - - - +
-
-
NameTypeAttributesDescription
params - - -Object - - - - <optional>
- + - + - -
-

Clients parameters.

- - + - - - - - - + - + - - - + - + - - - + - - - - - + - + - - - +
Type:
+ - - - - - - - + + - - - + +
+

permissions :external:RestClient

- -
- - - -
NameTypeAttributesDescription
per_page - - -Number + +
Source:
+
+ + - -
- - <optional>
- + + - - -
-

Number of results per page.

- -
page - - -Number - - - - <optional>
- - + - -
-

Page number, zero indexed.

- -
- -
cb - - -function - - - - <optional>
- - - - - -
-

Callback function.

- -
- - + + + + + + + + + + + -
-
Returns:
+ +
Source:
+
+ - + -
-
- Type: -
-
- -Promise -| + -undefined + +
- - +
Type:
+
+ + -
-
Example
-

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
 
-management.getClients(params, function (err, clients) {
-  console.log(clients.length);
-});
-
-
- - - -

getConnection(params, cbopt) → {Promise|undefined}

+
+

recoveryCodeRegenerations :external:RestClient

-
-

Get an Auth0 connection.

+

Provides an abstraction layer for regenerating Guardian recovery codes.

@@ -8462,7 +9339,7 @@

getConne
Source:
@@ -8475,263 +9352,142 @@

getConne +

Type:
+ -
Parameters:
- - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + +
Source:
+
+ - - - - + - +
Type:
+
    +
  • -
- + + - - - - - -
NameTypeAttributesDescription
params - -Object +
+

roles :external:RestClient

- -
- - +
+

Provides an abstraction layer for CRD on roles for a user

+
- -
-

Connection parameters.

- - - - - - - - - +
- + - + -
- - + - - - - - + - + - + - + - - + - -
NameTypeDescription
id - - -String + + - - -

Connection ID.

- -
- -
cb - - -function + + - - - - <optional>
- +external:RestClient - - -
-

Callback function.

- -
+
+ + +
+

userLogs :external:RestClient

+
+

Provides a simple abstraction layer for user logs

+
+
+ -
-
Returns:
+ - + -
-
- Type: -
-
- -Promise -| + -undefined + + -
-
+ + -
+ + -
-
Example
- -
management.getConnection({ id: CONNECTION_ID }, function (err, connection) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(connection);
-});
- -
- -
- - -
- - - -

getConnections(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all connections.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - +
Source:
@@ -8744,2525 +9500,116 @@

getConn - - - - - - -

Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
Type:
+
    +
  • - -
- - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Connections params.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number, zero indexed.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
+external:RestClient + + +
- - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
-
-management.getConnections(params, function (err, connections) {
-  console.log(connections.length);
-});
- -
- -
- - -
- - - -

getDailyStats(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get the daily stats.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Stats parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
from - - -String - - - - -

The first day in YYYYMMDD format.

- -
to - - -String - - - - -

The last day in YYYYMMDD format.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = {
-  from: '{YYYYMMDD}',  // First day included in the stats.
-  to: '{YYYYMMDD}'  // Last day included in the stats.
-};
-
-management.getDaily(params, function (err, stats) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(stats);
-});
- -
- -
- - -
- - - -

getDeviceCredentials(cbopt) → {Promise|undefined}

- - - - - -
-

Get all Auth0 credentials.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.getDeviceCredentials(function (err, credentials) {
-  console.log(credentials.length);
-});
- -
- -
- - -
- - - -

getEmailProvider(cbopt) → {Promise|undefined}

- - - - - -
-

Get the email provider.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.getEmailProvider(function (err, provider) {
-  console.log(provider.length);
-});
- -
- -
- - -
- - - -

getGuardianEnrollment(data, cbopt) → {Promise|undefined}

- - - - - -
-

Get a single Guardian enrollment.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The Guardian enrollment data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The Guardian enrollment id.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) {
-  console.log(enrollment);
-});
- -
- -
- - -
- - - -

getGuardianEnrollments(data, cbopt) → {Promise|undefined}

- - - - - -
-

Get a list of a user's Guardian enrollments.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The user data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
-  console.log(enrollments);
-});
- -
- -
- - -
- - - -

getJob(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get a job by its ID.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Job parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Job ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = {
-  id: '{JOB_ID}'
-};
-
-management.getJob(params, function (err, job) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Retrieved job.
-  console.log(job);
-});
- -
- -
- - -
- - - -

getLog(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get an Auth0 log.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Log parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Event ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.getLog({ id: EVENT_ID }, function (err, log) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(log);
-});
- -
- -
- - -
- - - -

getLogs(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all logs.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+

usersByEmail :external:RestClient

- -
- - +
+

Provides an abstraction layer for the new "users-by-email" API

+
- - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Logs params.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
q - - -String - - - - - - <optional>
- - - - - -
-

Search Criteria using Query String Syntax

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number. Zero based

- -
per_page - - -Number - - - - - - <optional>
- - - - - -
-

The amount of entries per page

- -
sort - - -String - - - - - - <optional>
- - - - - -
-

The field to use for sorting.

- -
fields - - -String - - - - - - <optional>
- - - - - -
-

A comma separated list of fields to include or exclude

- -
include_fields - - -Boolean - - - - - - <optional>
- - - - - -
-

true if the fields specified are to be included in the result, false otherwise.

- -
include_totals - - -Boolean - - - - - - <optional>
- - - - - -
-

true if a query summary must be included in the result, false otherwise. Default false

- -
- - -
cb - - -function - - + - - - <optional>
- - - -
-

Callback function.

- -
+
+ + + + + + + + + + -
-
Returns:
+ - + -
-
- Type: -
-
- -Promise -| + +
Source:
+
+ -undefined + + - +
- -
+
Type:
+ + -

- This method takes an optional object as first argument that may be used to - specify pagination settings and the search query. If pagination options are - not present, the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 2
-};
 
-management.getLogs(params, function (err, logs) {
-  console.log(logs.length);
-});
-

+ + + + + +

Methods

+
-

getResourceServer(params, cbopt) → {Promise|undefined}

+

assignPermissions(params, data, cbopt) → {Promise|undefined}

-

Get a Resource Server.

+

Assign permissions to a user

@@ -11298,7 +9645,7 @@

getR
Source:
@@ -11350,7 +9697,7 @@

Parameters:
-Object +object @@ -11369,7 +9716,7 @@
Parameters:
-

Resource Server parameters.

+

params object

@@ -11401,7 +9748,92 @@
Parameters:
-String +string + + + + + + + + + + +

user_id

+ + + + + + + + + + + + + + + + + data + + + + + +string + + + + + + + + + + + + + + + + + + +

data object containing list of permissions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11507,12 +9939,15 @@
Returns:
Example
-
management.getResourceServer({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) {
+    
var params =  { id : 'USER_ID';
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.users.assignPermissions(params, data, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  console.log(resourceServer);
+  // permissions added.
 });
@@ -11524,14 +9959,14 @@
Example
-

getResourceServers(paramsopt, cbopt) → {Promise|undefined}

+

assignRoles(params, data, cbopt) → {Promise|undefined}

-

Get all resource servers.

+

Assign roles to a user

@@ -11567,7 +10002,7 @@

get
Source:
@@ -11608,18 +10043,103 @@

Parameters:
-
+ + + + + + + + + + + + + + + + + + + - + - - @@ -11668,70 +10184,24 @@
Parameters:
- - - - - - - - - - - - - - - - - - - + - - @@ -11826,20 +10296,15 @@
Returns:
Example
-

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
+    
var params =  { id : 'USER_ID';
+var data = { "roles" : ["roleId1", "roleID2"]};
+
+management.users.assignRoles(params, data, function (err, user) {
+  if (err) {
+    // Handle error.
+  }
 
-management.getResourceServers(params, function (err, resourceServers) {
-  console.log(resourceServers.length);
+  // roles added.
 });
@@ -11851,14 +10316,14 @@
Example
-

getRule(params, cbopt) → {Promise|undefined}

+

create(data, cbopt) → {Promise|undefined}

-

Get an Auth0 rule.

+

Create a new user.

@@ -11894,7 +10359,7 @@

getRuleSource:
@@ -11940,13 +10405,13 @@
Parameters:

- + @@ -12103,12 +10517,12 @@
Returns:
Example
-
management.getRule({ id: RULE_ID }, function (err, rule) {
+    
management.users.create(data, function (err) {
   if (err) {
     // Handle error.
   }
 
-  console.log(rule);
+  // User created.
 });
@@ -12120,14 +10534,14 @@
Example
-

getRules(paramsopt, cbopt) → {Promise|undefined}

+

delete(params, cbopt) → {Promise|undefined}

-

Get all rules.

+

Delete a user by its id.

@@ -12163,7 +10577,7 @@

getRulesSource:
@@ -12215,7 +10629,7 @@
Parameters:

- - @@ -12264,70 +10674,24 @@
Parameters:
- - - - - - - - - - - - - - - - - - - + - - @@ -12371,7 +10735,7 @@
Parameters:
@@ -12422,20 +10786,12 @@
Returns:
Example
-

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
+    
management.users.delete({ id: USER_ID }, function (err) {
+  if (err) {
+    // Handle error.
+  }
 
-management.getRules(params, function (err, rules) {
-  console.log(rules.length);
+  // User deleted.
 });
@@ -12447,14 +10803,14 @@
Example
-

getRulesConfigs() → {Promise|undefined}

+

deleteAll(cbopt) → {Promise|undefined}

-

Get rules config.

+

Delete all users.

@@ -12478,6 +10834,8 @@

getRul +
Deprecated:
  • This method will be removed in the next major release.
+ @@ -12490,7 +10848,7 @@

getRul
Source:
@@ -12509,6 +10867,70 @@

getRul +

Parameters:
+ + +
NameTypeDescription
permissions + + +string @@ -11412,7 +9844,7 @@
Parameters:
-

Resource Server ID.

+

Array of permission IDs

params + + +object + + + + + + + + + + +

params object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

user_id

+ +
+ + +
paramsdata -Object +string @@ -11628,8 +10148,6 @@
Parameters:
- <optional>
- @@ -11640,7 +10158,7 @@
Parameters:
-

Resource Servers parameters.

+

data object containing list of role IDs

@@ -11654,8 +10172,6 @@
Parameters:
TypeAttributes
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
pageroles -Number +string - - <optional>
- - - - - -
-

Page number, zero indexed.

+

Array of role IDs

paramsdata -Object +object @@ -11965,58 +10430,7 @@
Parameters:
-

Rule parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Rule ID.

- -
- +

User data.

-Object +object @@ -12224,8 +10638,6 @@
Parameters:
- <optional>
- @@ -12236,7 +10648,7 @@
Parameters:
-

Rules parameters.

+

The user data object..

@@ -12250,8 +10662,6 @@
Parameters:
TypeAttributes
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
pageid -Number +string - - <optional>
- - - - - -
-

Page number, zero indexed.

+

The user id.

-

Callback function.

+

Callback function

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
cb + + +function + + + + + + <optional>
+ + + + + +
+

Callback function

+ +
+ + @@ -12550,12 +10972,12 @@
Returns:
Example
-
management.getRulesConfigs(function (err, rulesConfigs) {
+    
management.users.deleteAll(function (err) {
   if (err) {
     // Handle error.
   }
 
-  // Get Rules Configs.
+  // Users deleted
 });
@@ -12567,14 +10989,14 @@
Example
-

getTenantSettings(cbopt) → {Promise|undefined}

+

deleteMultifactorProvider(params, cbopt) → {Promise|undefined}

-

Get the tenant settings..

+

Delete a multifactor provider.

@@ -12610,7 +11032,7 @@

getT
Source:
@@ -12654,6 +11076,117 @@

Parameters:
+ + + params + + + + + +object + + + + + + + + + + + + + + + + + + +

Data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
provider + + +string + + + + +

Multifactor provider.

+ +
+ + + + + + + cb @@ -12683,7 +11216,7 @@
Parameters:
-

Callback function.

+

Callback function

@@ -12734,12 +11267,14 @@
Returns:
Example
-
management.getSettings(function (err, settings) {
+    
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
+
+management.users.deleteMultifactorProvider(params, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  console.log(settings);
+  // Users accounts unlinked.
 });
@@ -12751,7 +11286,7 @@
Example
-

getUser(data, cbopt) → {Promise|undefined}

+

get(data, cbopt) → {Promise|undefined}

@@ -12794,7 +11329,7 @@

getUserSource:
@@ -12846,7 +11381,7 @@
Parameters:
-Object +object @@ -12897,7 +11432,7 @@
Parameters:
-String +string @@ -13003,7 +11538,7 @@
Returns:
Example
-
management.getUser({ id: USER_ID }, function (err, user) {
+    
management.users.get({ id: USER_ID }, function (err, user) {
   console.log(user);
 });
@@ -13016,14 +11551,14 @@
Example
-

getUserLogs(params, cbopt) → {Promise|undefined}

+

getAll(paramsopt, cbopt) → {Promise|undefined}

-

Get user's log events.

+

Get all users.

@@ -13059,7 +11594,7 @@

getUserLog
Source:
@@ -13111,7 +11646,7 @@

Parameters:
-Object +object @@ -13120,6 +11655,8 @@
Parameters:
+ <optional>
+ @@ -13130,7 +11667,7 @@
Parameters:
-

Get logs data.

+

Users params.

@@ -13144,6 +11681,8 @@
Parameters:
Type + Attributes + @@ -13156,44 +11695,28 @@
Parameters:
- id + per_page -String +number - - - - -

User id.

+ - - - - - - - - per_page - - - - + <optional>
-Number + - - - + + @@ -13214,70 +11737,28 @@
Parameters:
-Number +number - - - - -

Page number, zero indexed.

+ - - - - - - - - sort - - - - + <optional>
-String - - - - - - - - - -

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

- - - - - - - - include_totals - - - -Boolean - - - - - + -

true if a query summary must be included in the result, false otherwise. Default false;

+

Page number, zero indexed.

@@ -13372,14 +11853,20 @@
Returns:
Example
-
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
-
-management.getUserLogs(params, function (err, logs) {
-  if (err) {
-    // Handle error.
-  }
+        

+ This method takes an optional object as first argument that may be used to + specify pagination settings and the search query. If pagination options are + not present, the first page of a limited number of results will be returned. +

+ +
// Pagination settings.
+var params = {
+  per_page: 10,
+  page: 0
+};
 
-  console.log(logs);
+management.users.getAll(params, function (err, users) {
+  console.log(users.length);
 });
@@ -13391,14 +11878,14 @@
Example
-

getUsers(paramsopt, cbopt) → {Promise|undefined}

+

getByEmail(emailopt, optionsopt, cbopt) → {Promise|undefined}

-

Get all users.

+

Get Users by an Email Address

@@ -13434,7 +11921,7 @@

getUsersSource:
@@ -13480,13 +11967,49 @@
Parameters:
- params + email + + + + + +string + + + + + + + + + <optional>
+ + + + + + + + + + + +

Email address of user(s) to find

+ + + + + + + + + options -Object +object @@ -13507,7 +12030,7 @@
Parameters:
-

Users params.

+

Additional options to pass to the endpoint

@@ -13535,49 +12058,13 @@
Parameters:
- search_engine - - - - - -Number - - - - - - - - - <optional>
- - - - - - - - - - - -

The version of the search engine to use.

- - - - - - - - - per_page + fields -Number +string @@ -13598,7 +12085,7 @@
Parameters:
-

Number of results per page.

+

Comma-separated list of fields to include or exclude in the result

@@ -13607,13 +12094,13 @@
Parameters:
- page + include_fields -Number +boolean @@ -13634,7 +12121,7 @@
Parameters:
-

Page number, zero indexed.

+

Whether specified fields are to be included (true) or excluded (false). Defaults to true.

@@ -13730,20 +12217,12 @@
Returns:
Example

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. + This method takes a first argument as the Email address to look for + users, and uses the /users-by-email API, not the search API

-
// Pagination settings.
-var params = {
-  search_engine: 'v3',
-  per_page: 10,
-  page: 0
-};
-
-auth0.getUsers(params, function (err, users) {
-  console.log(users.length);
+    
management.users.getByEmail('email@address', function (err, users) {
+  console.log(users);
 });

@@ -13755,14 +12234,14 @@
Example
-

getUsersByEmail(emailopt, cbopt) → {Promise|undefined}

+

getGuardianEnrollments(data, cbopt) → {Promise|undefined}

-

Get users for a given email address

+

Get a list of Guardian enrollments.

@@ -13798,7 +12277,7 @@

getUse
Source:
@@ -13844,13 +12323,13 @@

Parameters:
- email + data -String +object @@ -13859,8 +12338,6 @@
Parameters:
- <optional>
- @@ -13871,7 +12348,58 @@
Parameters:
-

Email Address of users to locate

+

The user data object.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ @@ -13958,13 +12486,8 @@
Returns:
Example
-

- This method takes an email address as the first argument, - and returns all users with that email address -

- -
auth0.getUsersByEmail(email, function (err, users) {
-  console.log(users);
+    
management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
+  console.log(enrollments);
 });
@@ -13976,15 +12499,14 @@
Example
-

importUsers(data, cbopt) → {Promise|undefined}

+

getInfo(accessToken, cbopt) → {Promise|undefined}

-

Given a path to a file and a connection id, create a new job that imports the -users contained in the file and associate them with the given connection.

+

Given an access token get the user profile linked to it.

@@ -14020,7 +12542,7 @@

importUser
Source:
@@ -14066,13 +12588,13 @@

Parameters:
- data + accessToken -Object +string @@ -14091,84 +12613,7 @@
Parameters:
-

Users import data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
connectionId - - -String - - - - -

Connection for the users insertion.

- -
users - - -String - - - - -

Path to the users data file.

- -
- +

User access token.

@@ -14255,15 +12700,18 @@
Returns:
Example
-
var params = {
-  connection_id: '{CONNECTION_ID}',
-  users: '{PATH_TO_USERS_FILE}'
-};
-
-management.get(params, function (err) {
+        

+ Get the user information based on the Auth0 access token (obtained during + login). Find more information in the + API Docs. +

+ +
auth0.users.getInfo(accessToken, function (err, userInfo) {
   if (err) {
     // Handle error.
   }
+
+  console.log(userInfo);
 });
@@ -14275,14 +12723,14 @@
Example
-

linkUsers(userId, params, cbopt) → {Promise|undefined}

+

getPermissions(data, cbopt) → {Promise|undefined}

-

Link the user with another account.

+

Get a list of permissions for a user.

@@ -14318,7 +12766,7 @@

linkUsersSource:
@@ -14364,47 +12812,13 @@
Parameters:
- userId - - - - - -String - - - - - - - - - - - - - - - - - - -

ID of the primary user.

- - - - - - - - - params + data -Object +object @@ -14423,7 +12837,7 @@
Parameters:
-

Secondary user data.

+

The user data object.

@@ -14440,48 +12854,22 @@
Parameters:
- Description - - - - - - - - - user_id - - - - - -String - - - - - - - - - - -

ID of the user to be linked.

- - - + Description + + + - connection_id + id -String +string @@ -14492,7 +12880,7 @@
Parameters:
-

ID of the connection to be used.

+

The user id.

@@ -14587,18 +12975,8 @@
Returns:
Example
-
var userId = 'USER_ID';
-var params = {
-  user_id: 'OTHER_USER_ID',
-  connection_id: 'CONNECTION_ID'
-};
-
-management.linkUsers(userId, params, function (err, user) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Users linked.
+    
management.users.getPermissions({ id: USER_ID }, function (err, permissions) {
+  console.log(permissions);
 });
@@ -14610,14 +12988,14 @@
Example
-

regenerateRecoveryCode(data, cbopt) → {Promise|undefined}

+

getRoles(data, cbopt) → {Promise|undefined}

-

Generate new Guardian recovery code.

+

Get a list of roles for a user.

@@ -14653,7 +13031,7 @@

Source:
@@ -14705,7 +13083,7 @@

Parameters:
-Object +object @@ -14756,7 +13134,7 @@
Parameters:
-String +string @@ -14862,8 +13240,8 @@
Returns:
Example
-
management.regenerateRecoveryCode({ id: USER_ID }, function (err, newRecoveryCode) {
-  console.log(newRecoveryCode);
+    
management.users.getRoles({ id: USER_ID }, function (err, roles) {
+  console.log(roles);
 });
@@ -14875,14 +13253,14 @@
Example
-

sendEmailVerification(data, cbopt) → {Promise|undefined}

+

getUserOrganizations(data, cbopt) → {Promise|undefined}

-

Send a verification email to a user.

+

Get a list of organizations for a user.

@@ -14918,7 +13296,7 @@

Source:
@@ -14970,7 +13348,7 @@

Parameters:
-Object +object @@ -14989,7 +13367,7 @@
Parameters:
-

User data object.

+

The user data object.

@@ -15015,13 +13393,13 @@
Parameters:
- user_id + id -String +string @@ -15032,7 +13410,7 @@
Parameters:
-

ID of the user to be verified.

+

The user id.

@@ -15127,14 +13505,8 @@
Returns:
Example
-
var params = {
-	user_id: '{USER_ID}'
-};
-
-management.sendEmailVerification(function (err) {
-  if (err) {
-    // Handle error.
-  }
+    
management.users.getUserOrganizations({ id: USER_ID }, function (err, orgs) {
+  console.log(orgs);
 });
@@ -15146,14 +13518,14 @@
Example
-

setRulesConfig(params, data, cbopt) → {Promise|undefined}

+

impersonate(userId, settings, cbopt) → {Promise|undefined}

-

Set a new rules config.

+

Impersonate the user with the given user ID.

@@ -15189,7 +13561,7 @@

setRule
Source:
@@ -15235,13 +13607,47 @@

Parameters:
- params + userId + + + + + +string + + + + + + + + + + + + + + + + + + +

User ID token.

+ + + + + + + + + settings -Object +object @@ -15260,7 +13666,7 @@
Parameters:
-

Rule Config parameters.

+

Impersonation settings.

@@ -15274,6 +13680,8 @@
Parameters:
Type + Attributes + @@ -15286,32 +13694,32 @@
Parameters:
- key + impersonator_id -String +string + + - + - -

Rule Config key.

- - + + - - - + + +

Impersonator user ID.

@@ -15320,13 +13728,13 @@
Parameters:
- data + protocol -Object +string @@ -15345,50 +13753,77 @@
Parameters:
-

Rule Config Data parameters.

+

The authentication protocol.

- + + - - - - - - + - + + + + - + - - + + + + + + + + + + + - - + + + @@ -15483,15 +13918,24 @@
Returns:
Example
-
var params = { key: RULE_CONFIG_KEY };
-var data =   { value: RULES_CONFIG_VALUE };
+        

+ Gets a link that can be used once to log in as a specific user. Useful for + troubleshooting. Find more information in the + [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate). +

+ +
var settings = {
+  impersonator_id: '{IMPERSONATOR_ID}',
+  protocol: 'oauth2',
+  additionalParameters: {}  // Optional additional params.
+};
 
-management.setRulesConfig(params, data, function (err, rulesConfig) {
+auth0.users.impersonate(userId, settings, function (err, link) {
   if (err) {
     // Handle error.
   }
 
-  // Rules Config set.
+  console.log(link);
 });
@@ -15503,14 +13947,14 @@
Example
-

unlinkUsers(params, cbopt) → {Promise|undefined}

+

invalidateRememberBrowser(params, cbopt) → {Promise|undefined}

-

Unlink the given accounts.

+

Invalidate all remembered browsers for MFA.

@@ -15546,7 +13990,7 @@

unlinkUser
Source:
@@ -15598,7 +14042,7 @@

Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -15807,14 +14199,12 @@
Returns:
Example
-
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };
-
-management.unlinkUsers(params, function (err, user) {
+    
management.users.invalidateRememberBrowser({ id: USER_ID }, function (err, result) {
   if (err) {
     // Handle error.
   }
 
-  // Users accounts unlinked.
+  // Invalidated all remembered browsers.
 });
@@ -15826,14 +14216,14 @@
Example
-

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

+
-

Update the app metadata for a user.

+

Link the user with another account.

@@ -15869,7 +14259,7 @@

upda
Source:
@@ -15913,6 +14303,40 @@

Parameters:
+ + + + + + + + + + + + + + + + + + @@ -15921,7 +14345,7 @@
Parameters:
- + + + + + + + + + + + + + + + + + - + - -
NameType
token + + +string - - Description
+ + + + + + +

API v1 token obtained for impersonation

+ +
valueclientId -String +string + + <optional>
+ + + + + +
-

Rule Config Data value.

+

Client id used for impersonation. Uses the one supplied in the constructor by default.

-Object +object @@ -15617,7 +14061,7 @@
Parameters:
-

Linked users data.

+

The user data object.

@@ -15649,59 +14093,7 @@
Parameters:
-String - - - - -

Primary user ID.

- -
provider - - -String - - - - -

Identity provider in use.

- -
user_id - - -String +string @@ -15712,7 +14104,7 @@
Parameters:
-

Secondary user ID.

+

The user id.

userId + + +string + + + + + + + + + + +

ID of the primary user.

+ +
params -Object +object @@ -15940,7 +14364,7 @@
Parameters:
-

The user data object..

+

Secondary user data.

@@ -15961,18 +14385,44 @@
Parameters:
user_id + + +string + + + + +

ID of the user to be linked.

+ +
idconnection_id -String +string @@ -15983,15 +14433,33 @@
Parameters:
-

The user id.

+

ID of the connection to be used.

+ + + provider + + + + + +string + + + + + + + + + + +

Identity provider of the secondary user account being linked.

@@ -16000,32 +14468,32 @@
Parameters:
- metadata + link_with -Object +string - - - + + +

JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent.

- - + + - + + + - -

New app metadata.

@@ -16061,7 +14529,7 @@
Parameters:
-

Callback function

+

Callback function.

@@ -16112,18 +14580,18 @@
Returns:
Example
-
var params = { id: USER_ID };
-var metadata = {
-  foo: 'bar'
+    
var userId = 'USER_ID';
+var params = {
+  user_id: 'OTHER_USER_ID',
+  connection_id: 'CONNECTION_ID'
 };
 
-management.updateAppMetadata(params, metadata, function (err, user) {
+management.users.link(userId, params, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  // Updated user.
-  console.log(user);
+  // Users linked.
 });
@@ -16135,14 +14603,14 @@
Example
-

updateClient(params, data, cbopt) → {Promise|undefined}

+

logs(params, cbopt) → {Promise|undefined}

-

Update an Auth0 client.

+

Get user's log events.

@@ -16178,7 +14646,7 @@

updateCli
Source:
@@ -16230,7 +14698,7 @@

Parameters:
-Object +object @@ -16249,7 +14717,7 @@
Parameters:
-

Client parameters.

+

Get logs data.

@@ -16275,13 +14743,13 @@
Parameters:
- client_id + id -String +string @@ -16292,15 +14760,33 @@
Parameters:
-

Application client ID.

+

User id.

- - + + + per_page + + + + + +number + + + + + + + + + + +

Number of results per page.

@@ -16309,32 +14795,84 @@
Parameters:
- data + page -Object +number - + + + + +

Page number, zero indexed.

+ + + + + + + + + sort + + + + +string + + + + + + + + + +

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

+ + + + + + + + include_totals + + + - +boolean + + + + + -

Updated client data.

+

true if a query summary must be included in the result, false otherwise. Default false;

+ + + + + + + + @@ -16421,15 +14959,14 @@
Returns:
Example
-
var data = { name: 'newClientName' };
-var params = { client_id: CLIENT_ID };
+    
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
 
-management.updateClient(params, data, function (err, client) {
+management.users.logs(params, function (err, logs) {
   if (err) {
     // Handle error.
   }
 
-  console.log(client.name);  // 'newClientName'
+  console.log(logs);
 });
@@ -16441,14 +14978,14 @@
Example
-

updateConnection(params, data, cbopt) → {Promise|undefined}

+

regenerateRecoveryCode(params, cbopt) → {Promise|undefined}

-

Update an existing connection.

+

Generate new Guardian recovery code.

@@ -16484,7 +15021,7 @@

updat
Source:
@@ -16536,7 +15073,7 @@

Parameters:
-Object +object @@ -16555,7 +15092,7 @@
Parameters:
-

Connection parameters.

+

Get logs data.

@@ -16587,7 +15124,7 @@
Parameters:
-String +string @@ -16598,7 +15135,7 @@
Parameters:
-

Connection ID.

+

User id.

@@ -16613,40 +15150,6 @@
Parameters:
- - - data - - - - - -Object - - - - - - - - - - - - - - - - - - -

Updated connection data.

- - - - - - cb @@ -16727,15 +15230,8 @@
Returns:
Example
-
var data = { name: 'newConnectionName' };
-var params = { id: CONNECTION_ID };
-
-management.updateConnection(params, data, function (err, connection) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(connection.name);  // 'newConnectionName'
+    
management.users.regenerateRecoveryCode("USER_ID", function (err, result) {
+  console.log(result.recovery_code);
 });
@@ -16747,14 +15243,14 @@
Example
-

updateEmailProvider(params, data, cbopt) → {Promise|undefined}

+

removePermissions(params, data, cbopt) → {Promise|undefined}

-

Update the email provider.

+

Remove permissions from a user

@@ -16790,7 +15286,7 @@

up
Source:
@@ -16819,30 +15315,115 @@

Parameters:
Name - Type + Type + + + Attributes + + + + + Description + + + + + + + + + params + + + + + +object + + + + + + + + + + + + + + + + + + +

params object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - + + - - - + + +
NameTypeDescription
id + + +string + + + + Attributes +

user_id

+ +
Description
+ + + + - - params + data -Object +object @@ -16861,41 +15442,58 @@
Parameters:
-

Email provider parameters.

+

data object containing list of permission IDs

- - + + + + + + + + + + + + + + + + + + + - + - - + + - + + +
NameTypeDescription
datapermissions -Object +string - - + + +

Array of permission IDs

-
- -

Updated email provider data.

@@ -16982,13 +15580,15 @@
Returns:
Example
-
management.updateEmailProvider(params, data, function (err, provider) {
+    
var params =  { id : 'USER_ID';
+var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+
+management.users.removePermissions(params, data, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  // Updated email provider.
-  console.log(provider);
+  // permissions removed.
 });
@@ -17000,14 +15600,14 @@
Example
-

updateResourceServer(params, data, cbopt) → {Promise|undefined}

+

removeRoles(params, data, cbopt) → {Promise|undefined}

-

Update an existing resource server.

+

Remove roles from a user

@@ -17043,7 +15643,7 @@

u
Source:
@@ -17095,7 +15695,7 @@

Parameters:
-Object +object @@ -17114,7 +15714,7 @@
Parameters:
-

Resource Server parameters.

+

params object

@@ -17146,7 +15746,7 @@
Parameters:
-String +string @@ -17157,7 +15757,7 @@
Parameters:
-

Resource Server ID.

+

user_id

@@ -17180,7 +15780,7 @@
Parameters:
-Object +string @@ -17199,7 +15799,58 @@
Parameters:
-

Updated Resource Server data.

+

data object containing list of role IDs

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
roles + + +string + + + + +

Array of role IDs

+ +
+ @@ -17286,15 +15937,15 @@
Returns:
Example
-
var data = { name: 'newResourceServerName' };
-var params = { id: RESOURCE_SERVER_ID };
+    
var params =  { id : 'USER_ID';
+var data = { "roles" : ["roleId1", "roleID2"]};
 
-management.updateResourceServer(params, data, function (err, resourceServer) {
+management.users.removeRoles(params, data, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  console.log(resourceServer.name);  // 'newResourceServerName'
+  // roles removed.
 });
@@ -17306,14 +15957,14 @@
Example
-

updateRule(params, data, cbopt) → {Promise|undefined}

+
-

Update an existing rule.

+

Unlink the given accounts.

@@ -17349,7 +16000,7 @@

updateRule<
Source:
@@ -17401,7 +16052,7 @@

Parameters:
-Object +object @@ -17420,7 +16071,7 @@
Parameters:
-

Rule parameters.

+

Linked users data.

@@ -17452,7 +16103,7 @@
Parameters:
-String +string @@ -17463,15 +16114,33 @@
Parameters:
-

Rule ID.

+

Primary user ID.

- - + + + provider + + + + + +string + + + + + + + + + + +

Identity provider in use.

@@ -17480,32 +16149,32 @@
Parameters:
- data + user_id -Object +string - - - + + +

Secondary user ID.

- - + + - + + + - -

Updated rule data.

@@ -17592,14 +16261,14 @@
Returns:
Example
-
var params = { id: RULE_ID };
-var data = { name: 'my-rule'};
-management.updateRule(params, data, function (err, rule) {
+    
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };
+
+management.users.unlink(params, function (err, user) {
   if (err) {
     // Handle error.
   }
 
-  console.log(rule.name); // 'my-rule'.
+  // Users accounts unlinked.
 });
@@ -17611,14 +16280,14 @@
Example
-

updateTenantSettings(data, cbopt) → {Promise|undefined}

+

update(params, data, cbopt) → {Promise|undefined}

-

Update the tenant settings.

+

Update a user by its id.

@@ -17654,7 +16323,7 @@

u
Source:
@@ -17698,6 +16367,91 @@

Parameters:
+ + + params + + + + + +object + + + + + + + + + + + + + + + + + + +

The user parameters.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +string + + + + +

The user id.

+ +
+ + + + + + + data @@ -17706,7 +16460,7 @@
Parameters:
-Object +object @@ -17725,7 +16479,7 @@
Parameters:
-

The new tenant settings.

+

New user data.

@@ -17761,7 +16515,7 @@
Parameters:
-

Callback function.

+

Callback function

@@ -17812,10 +16566,15 @@
Returns:
Example
-
management.updateTenantSettings(data, function (err) {
+    
var params = { id: USER_ID };
+
+management.users.update(params, data, function (err, user) {
   if (err) {
     // Handle error.
   }
+
+  // Updated user.
+  console.log(user);
 });
@@ -17827,14 +16586,14 @@
Example
-

updateUser(params, data, cbopt) → {Promise|undefined}

+

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

-

Update a user by its id.

+

Update the app metadata.

@@ -17870,7 +16629,7 @@

updateUser<
Source:
@@ -17922,7 +16681,7 @@

Parameters:
-Object +object @@ -17941,7 +16700,7 @@
Parameters:
-

The user parameters.

+

The user data object..

@@ -17973,7 +16732,7 @@
Parameters:
-String +string @@ -18001,13 +16760,13 @@
Parameters:
- data + metadata -Object +object @@ -18026,7 +16785,7 @@
Parameters:
-

New user data.

+

New app metadata.

@@ -18114,8 +16873,11 @@
Returns:
Example
var params = { id: USER_ID };
+var metadata = {
+  foo: 'bar'
+};
 
-management.updateUser(params, data, function (err, user) {
+management.users.updateAppMetadata(params, metadata, function (err, user) {
   if (err) {
     // Handle error.
   }
@@ -18140,7 +16902,7 @@ 

upd
-

Update the user metadata for a user.

+

Update the user metadata.

@@ -18176,7 +16938,7 @@

upd
Source:
@@ -18228,7 +16990,7 @@

Parameters:
-Object +object @@ -18279,7 +17041,7 @@
Parameters:
-String +string @@ -18313,7 +17075,7 @@
Parameters:
-Object +object @@ -18424,7 +17186,7 @@
Example
address: '123th Node.js Street' }; -management.updateUserMetadata(params, metadata, function (err, user) { +management.users.updateUserMetadata(params, metadata, function (err, user) { if (err) { // Handle error. } @@ -18454,7 +17216,7 @@
Example

- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/auth_DatabaseAuthenticator.js.html b/docs/auth_DatabaseAuthenticator.js.html index 9cfabf416..ef9614582 100644 --- a/docs/auth_DatabaseAuthenticator.js.html +++ b/docs/auth_DatabaseAuthenticator.js.html @@ -24,7 +24,8 @@
@@ -39,298 +40,284 @@

auth/DatabaseAuthenticator.js

-
var extend = require('util')._extend;
-
-var ArgumentError = require('rest-facade').ArgumentError;
-var RestClient = require('rest-facade').Client;
+            
const { ArgumentError } = require('rest-facade');
+const RestClient = require('rest-facade').Client;
 
 /**
- * @class
  * Abstracts the sign-in, sign-up and change-password processes for Database &
  * Active Directory authentication services.
- * @constructor
- * @memberOf module:auth
- *
- * @param  {Object}              options            Authenticator options.
- * @param  {String}              options.baseUrl    The auth0 account URL.
- * @param  {String}              [options.clientId] Default client ID.
- * @param  {OAuthAuthenticator}  oauth              OAuthAuthenticator instance.
  */
-var DatabaseAuthenticator = function(options, oauth) {
-  if (!options) {
-    throw new ArgumentError('Missing authenticator options');
+class DatabaseAuthenticator {
+  /**
+   * @param  {object}              options            Authenticator options.
+   * @param  {string}              options.baseUrl    The auth0 account URL.
+   * @param  {string}              [options.clientId] Default client ID.
+   * @param  {OAuthAuthenticator}  oauth              OAuthAuthenticator instance.
+   */
+  constructor(options, oauth) {
+    if (!options) {
+      throw new ArgumentError('Missing authenticator options');
+    }
+
+    if (typeof options !== 'object') {
+      throw new ArgumentError('The authenticator options must be an object');
+    }
+
+    /**
+     * Options object for the Rest Client instance.
+     *
+     * @type {object}
+     */
+    const clientOptions = {
+      errorFormatter: { message: 'message', name: 'error' },
+      headers: options.headers,
+    };
+
+    this.oauth = oauth;
+    this.dbConnections = new RestClient(`${options.baseUrl}/dbconnections/:type`, clientOptions);
+    this.clientId = options.clientId;
   }
 
-  if (typeof options !== 'object') {
-    throw new ArgumentError('The authenticator options must be an object');
+  /**
+   * Sign in using a database or active directory service.
+   *
+   * @example <caption>
+   *   Given the user credentials and the connection specified, it will do the
+   *   authentication on the provider and return a JSON with the `access_token`
+   *   and `id_token`. Find more information about the structure of the data
+   *   object in the <a href="https://auth0.com/docs/auth-api#!#post--oauth-ro">
+   *   API docs</a>.
+   * </caption>
+   *
+   * var data = {
+   *   username: '{USERNAME}',
+   *   password: '{PASSWORD}',
+   *   connection: 'Username-Password-Authentication' // Optional field.
+   * };
+   *
+   * auth0.database.signIn(data, function (err, userData) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(userData);
+   * });
+   * @param   {object}    userData              User credentials object.
+   * @param   {string}    userData.username     Username.
+   * @param   {string}    userData.password     User password.
+   * @param   {string}    userData.connection   Identity provider in use.
+   * @param   {Function}  [cb]              Method callback.
+   * @returns  {Promise|undefined}
+   */
+  signIn(userData, cb) {
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
+
+    const data = {
+      connection: 'Username-Password-Authentication',
+      ...userData,
+    };
+
+    if (typeof data.username !== 'string' || data.username.trim().length === 0) {
+      throw new ArgumentError('username field is required');
+    }
+
+    if (typeof data.password !== 'string' || data.password.trim().length === 0) {
+      throw new ArgumentError('password field is required');
+    }
+
+    return this.oauth.signIn(data, cb);
   }
 
   /**
-   * Options object for the Rest Client instace.
+   * Sign up using a database or active directory service.
    *
-   * @type {Object}
+   * @example <caption>
+   *   Given the user credentials, the connection specified and (optionally) the
+   *   client ID, it will create a new user. Find more information in the
+   *   <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-signup">
+   *   API Docs</a>.
+   * </caption>
+   *
+   * var data = {
+   *   email: '{EMAIL}',
+   *   password: '{PASSWORD}',
+   *   connection: 'Username-Password-Authentication' // Optional field.
+   * };
+   *
+   * auth0.database.signUp(data, function (err, userData) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(userData);
+   * });
+   * @param   {object}    userData              User credentials object.
+   * @param   {string}    userData.email        User email address.
+   * @param   {string}    userData.password     User password.
+   * @param   {string}    userData.connection   Identity provider in use.
+   * @param   {Function}  [cb]              Method callback.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' }
-  };
+  signUp(userData, cb) {
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
 
-  this.oauth = oauth;
-  this.dbConnections = new RestClient(options.baseUrl + '/dbconnections/:type', clientOptions);
-  this.clientId = options.clientId;
-};
+    const data = {
+      client_id: this.clientId,
+      ...userData,
+    };
 
-/**
- * Sign in using a database or active directory service.
- * @method    signIn
- * @memberOf  module:auth.DatabaseAuthenticator.prototype
- *
- * @example <caption>
- *   Given the user credentials and the connection specified, it will do the
- *   authentication on the provider and return a JSON with the `access_token`
- *   and `id_token`. Find more information about the structure of the data
- *   object in the <a href="https://auth0.com/docs/auth-api#!#post--oauth-ro">
- *   API docs</a>.
- * </caption>
- *
- * var data = {
- *   username: '{USERNAME}',
- *   password: '{PASSWORD}',
- *   connection: 'Username-Password-Authentication' // Optional field.
- * };
- *
- * auth0.database.signIn(data, function (err, userData) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(userData);
- * });
- *
- * @param   {Object}    data              User credentials object.
- * @param   {String}    data.username     Username.
- * @param   {String}    data.password     User password.
- * @param   {String}    data.connection   Identity provider in use.
- * @param   {Function}  [cb]              Method callback.
- *
- * @return  {Promise|undefined}
- */
-DatabaseAuthenticator.prototype.signIn = function(userData, cb) {
-  var defaultFields = {
-    connection: 'Username-Password-Authentication'
-  };
-  var data = extend(defaultFields, userData);
-
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
+    if (typeof data.email !== 'string' || data.email.trim().length === 0) {
+      throw new ArgumentError('email field is required');
+    }
 
-  if (typeof data.username !== 'string' || data.username.trim().length === 0) {
-    throw new ArgumentError('username field is required');
-  }
+    if (typeof data.password !== 'string' || data.password.trim().length === 0) {
+      throw new ArgumentError('password field is required');
+    }
 
-  if (typeof data.password !== 'string' || data.password.trim().length === 0) {
-    throw new ArgumentError('password field is required');
-  }
+    if (typeof data.connection !== 'string' || data.connection.trim().length === 0) {
+      throw new ArgumentError('connection field is required');
+    }
 
-  return this.oauth.signIn(data, cb);
-};
+    const params = {
+      type: 'signup',
+    };
 
-/**
- * Sign up using a database or active directory service.
- * @method    signUp
- * @memberOf  module:auth.DatabaseAuthenticator.prototype
- *
- * @example <caption>
- *   Given the user credentials, the connection specified and (optionally) the
- *   client ID, it will create a new user. Find more information in the
- *   <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-signup">
- *   API Docs</a>.
- * </caption>
- *
- * var data = {
- *   email: '{EMAIL}',
- *   password: '{PASSWORD}',
- *   connection: 'Username-Password-Authentication' // Optional field.
- * };
- *
- * auth0.database.signUp(data, function (err, userData) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(userData);
- * });
- *
- * @param   {Object}    data              User credentials object.
- * @param   {String}    data.email        User email address.
- * @param   {String}    data.password     User password.
- * @param   {Stinrg}    data.connection   Identity provider in use.
- * @param   {Function}  [cb]              Method callback.
- *
- * @return  {Promise|undefined}
- */
-DatabaseAuthenticator.prototype.signUp = function(userData, cb) {
-  var params = {
-    type: 'signup'
-  };
-  var defaultFields = {
-    client_id: this.clientId
-  };
-  var data = extend(defaultFields, userData);
-
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
+    if (cb && cb instanceof Function) {
+      return this.dbConnections.create(params, data, cb);
+    }
 
-  if (typeof data.email !== 'string' || data.email.trim().length === 0) {
-    throw new ArgumentError('email field is required');
+    return this.dbConnections.create(params, data);
   }
 
-  if (typeof data.password !== 'string' || data.password.trim().length === 0) {
-    throw new ArgumentError('password field is required');
-  }
+  /**
+   * Change password using a database or active directory service.
+   *
+   * @example <caption>
+   *   Given the user email, the connection specified and the new password to
+   *   use, Auth0 will send a forgot password email. Once the user clicks on the
+   *   confirm password change link, the new password specified in this POST will
+   *   be set to this user. Find more information in the
+   *   <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password>
+   *   API Docs</a>.
+   * </caption>
+   *
+   * var data = {
+   *   email: '{EMAIL}',
+   *   password: '{PASSWORD}',
+   *   connection: 'Username-Password-Authentication'
+   * };
+   *
+   * auth0.database.changePassword(data, function (err, message) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(message);
+   * });
+   * @param   {object}    userData              User credentials object.
+   * @param   {string}    userData.email        User email address.
+   * @param   {string}    userData.password     New password.
+   * @param   {string}    userData.connection   Identity provider in use.
+   * @param   {Function}  [cb]              Method callback.
+   * @returns  {Promise|undefined}
+   */
+  changePassword(userData, cb) {
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
 
-  if (typeof data.connection !== 'string' || data.connection.trim().length === 0) {
-    throw new ArgumentError('connection field is required');
-  }
+    const data = {
+      client_id: this.clientId,
+      ...userData,
+    };
 
-  if (cb && cb instanceof Function) {
-    return this.dbConnections.create(params, data, cb);
-  }
+    if (typeof data.email !== 'string' || data.email.trim().length === 0) {
+      throw new ArgumentError('email field is required');
+    }
 
-  return this.dbConnections.create(params, data);
-};
+    if (typeof data.password !== 'string' || data.password.trim().length === 0) {
+      throw new ArgumentError('password field is required');
+    }
 
-/**
- * Change password using a database or active directory service.
- *
- * @method    changePassword
- * @memberOf  module:auth.DatabaseAuthenticator.prototype
- *
- * @example <caption>
- *   Given the user email, the connection specified and the new password to
- *   use, Auth0 will send a forgot password email. Once the user clicks on the
- *   confirm password change link, the new password specified in this POST will
- *   be set to this user. Find more information in the
- *   <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password>
- *   API Docs</a>.
- * </caption>
- *
- * var data = {
- *   email: '{EMAIL}',
- *   password: '{PASSWORD}',
- *   connection: 'Username-Password-Authentication'
- * };
- *
- * auth0.database.changePassword(data, function (err, message) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(message);
- * });
- *
- * @param   {Object}    data              User credentials object.
- * @param   {String}    data.email        User email address.
- * @param   {String}    data.password     New password.
- * @param   {String}    data.connection   Identity provider in use.
- * @param   {Function}  [cb]              Method callback.
- *
- * @return  {Promise|undefined}
- */
-DatabaseAuthenticator.prototype.changePassword = function(userData, cb) {
-  var params = {
-    type: 'change_password'
-  };
-  var defaultFields = {
-    client_id: this.clientId
-  };
-  var data = extend(defaultFields, userData);
-
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
+    if (typeof data.connection !== 'string' || data.connection.trim().length === 0) {
+      throw new ArgumentError('connection field is required');
+    }
 
-  if (typeof data.email !== 'string' || data.email.trim().length === 0) {
-    throw new ArgumentError('email field is required');
-  }
+    const params = {
+      type: 'change_password',
+    };
 
-  if (typeof data.password !== 'string' || data.password.trim().length === 0) {
-    throw new ArgumentError('password field is required');
-  }
+    if (cb && cb instanceof Function) {
+      return this.dbConnections.create(params, data, cb);
+    }
 
-  if (typeof data.connection !== 'string' || data.connection.trim().length === 0) {
-    throw new ArgumentError('connection field is required');
+    return this.dbConnections.create(params, data);
   }
 
-  if (cb && cb instanceof Function) {
-    return this.dbConnections.create(params, data, cb);
-  }
+  /**
+   * Request a change password email using a database or active directory service.
+   *
+   * @example <caption>
+   *   Given the user email, the connection specified, Auth0 will send a change
+   *   password email. once the user clicks on the confirm password change link,
+   *   the new password specified in this POST will be set to this user. Find more
+   *   information in the <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password>
+   *   API Docs</a>.
+   * </caption>
+   *
+   * var data = {
+   *   email: '{EMAIL}',
+   *   connection: 'Username-Password-Authentication',
+   *   client_id: 'OS1VzKTVjizL0VCc9Hx2ae2aTPXWy6BD'
+   * };
+   *
+   * auth0.database.requestChangePasswordEmail(data, function (err, message) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(message);
+   * });
+   * @param   {object}    userData              User credentials object.
+   * @param   {string}    userData.email        User email address.
+   * @param   {string}    userData.connection   Identity provider in use.
+   * @param   {string}    userData.client_id    Client ID of the Application requesting the password change, to be included in the email template.
+   * @param   {Function}  [cb]              Method callback.
+   * @returns  {Promise|undefined}
+   */
+  requestChangePasswordEmail(userData, cb) {
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
 
-  return this.dbConnections.create(params, data);
-};
+    const data = {
+      client_id: this.clientId,
+      ...userData,
+    };
 
-/**
- * Request a change password email using a database or active directory service.
- *
- * @method    requestChangePasswordEmail
- * @memberOf  module:auth.DatabaseAuthenticator.prototype
- *
- * @example <caption>
- *   Given the user email, the connection specified, Auth0 will send a change
- *   password email. once the user clicks on the confirm password change link,
- *   the new password specified in this POST will be set to this user. Find more
- *   information in the <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password>
- *   API Docs</a>.
- * </caption>
- *
- * var data = {
- *   email: '{EMAIL}',
- *   connection: 'Username-Password-Authentication'
- * };
- *
- * auth0.database.requestChangePasswordEmail(data, function (err, message) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(message);
- * });
- *
- * @param   {Object}    data              User credentials object.
- * @param   {String}    data.email        User email address.
- * @param   {String}    data.connection   Identity provider in use.
- * @param   {Function}  [cb]              Method callback.
- *
- * @return  {Promise|undefined}
- */
-DatabaseAuthenticator.prototype.requestChangePasswordEmail = function(userData, cb) {
-  var params = {
-    type: 'change_password'
-  };
-  var defaultFields = {
-    client_id: this.clientId
-  };
-  var data = extend(defaultFields, userData);
-
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
+    if (typeof data.email !== 'string' || data.email.trim().length === 0) {
+      throw new ArgumentError('email field is required');
+    }
 
-  if (typeof data.email !== 'string' || data.email.trim().length === 0) {
-    throw new ArgumentError('email field is required');
-  }
+    if (typeof data.connection !== 'string' || data.connection.trim().length === 0) {
+      throw new ArgumentError('connection field is required');
+    }
 
-  if (typeof data.connection !== 'string' || data.connection.trim().length === 0) {
-    throw new ArgumentError('connection field is required');
-  }
+    const params = {
+      type: 'change_password',
+    };
 
-  if (cb && cb instanceof Function) {
-    return this.dbConnections.create(params, data, cb);
-  }
+    if (cb && cb instanceof Function) {
+      return this.dbConnections.create(params, data, cb);
+    }
 
-  return this.dbConnections.create(params, data);
-};
+    return this.dbConnections.create(params, data);
+  }
+}
 
 module.exports = DatabaseAuthenticator;
 
@@ -345,7 +332,7 @@

auth/DatabaseAuthenticator.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/auth_OAUthWithIDTokenValidation.js.html b/docs/auth_OAUthWithIDTokenValidation.js.html index c8d5b0180..30bab2628 100644 --- a/docs/auth_OAUthWithIDTokenValidation.js.html +++ b/docs/auth_OAUthWithIDTokenValidation.js.html @@ -24,7 +24,8 @@
@@ -39,101 +40,128 @@

auth/OAUthWithIDTokenValidation.js

-
var jwt = require('jsonwebtoken');
-var jwksClient = require('jwks-rsa');
-var Promise = require('bluebird');
+            
const jwt = require('jsonwebtoken');
+const jwksClient = require('jwks-rsa');
+const { ArgumentError } = require('rest-facade');
+const validateIdToken = require('./idToken').validate;
 
-var ArgumentError = require('rest-facade').ArgumentError;
+const HS256_IGNORE_VALIDATION_MESSAGE =
+  'Validation of `id_token` requires a `clientSecret` when using the HS256 algorithm. To ensure tokens are validated, please switch the signing algorithm to RS256 or provide a `clientSecret` in the constructor.';
 
 /**
- * @class
  * Abstracts the `oauth.create` method with additional id_token validation
- * @constructor
- * @memberOf module:auth
- *
- * @param  {Object}              oauth                           An instance of @type {OAuthAuthenticator}
- * @param  {Object}              options                         Authenticator options.
- * @param  {String}              options.domain                  AuthenticationClient server domain
- * @param  {String}              [options.clientId]              Default client ID.
- * @param  {String}              [options.clientSecret]          Default client Secret.
- * @param  {String}              [options.supportedAlgorithms]   Algorithms that your application expects to receive
  */
-var OAUthWithIDTokenValidation = function(oauth, options) {
-  if (!oauth) {
-    throw new ArgumentError('Missing OAuthAuthenticator param');
-  }
+class OAUthWithIDTokenValidation {
+  /**
+   * @param  {object}              oauth                               An instance of @type {OAuthAuthenticator}
+   * @param  {object}              options                             Authenticator options.
+   * @param  {string}              options.domain                      AuthenticationClient server domain
+   * @param  {string}              [options.clientId]                  Default client ID.
+   * @param  {string}              [options.clientSecret]              Default client Secret.
+   * @param  {string}              [options.supportedAlgorithms]       Algorithms that your application expects to receive
+   * @param  {boolean}             [options.__bypassIdTokenValidation] Whether the id_token should be validated or not
+   */
+  constructor(oauth, options) {
+    if (!oauth) {
+      throw new ArgumentError('Missing OAuthAuthenticator param');
+    }
 
-  if (!options) {
-    throw new ArgumentError('Missing authenticator options');
-  }
+    if (!options) {
+      throw new ArgumentError('Missing authenticator options');
+    }
 
-  if (typeof options !== 'object') {
-    throw new ArgumentError('The authenticator options must be an object');
-  }
+    if (typeof options !== 'object') {
+      throw new ArgumentError('The authenticator options must be an object');
+    }
 
-  this.oauth = oauth;
-  this.clientId = options.clientId;
-  this.clientSecret = options.clientSecret;
-  this.domain = options.domain;
-  this.supportedAlgorithms = options.supportedAlgorithms || ['HS256', 'RS256'];
-  this._jwksClient = jwksClient({
-    jwksUri: 'https://' + options.domain + '/.well-known/jwks.json'
-  });
-};
+    this.oauth = oauth;
+    this.__bypassIdTokenValidation = options.__bypassIdTokenValidation;
+    this.clientId = options.clientId;
+    this.clientSecret = options.clientSecret;
+    this.domain = options.domain;
+    this.supportedAlgorithms = options.supportedAlgorithms || ['HS256', 'RS256'];
+    this._jwksClient = jwksClient({
+      jwksUri: `https://${options.domain}/.well-known/jwks.json`,
+    });
+  }
 
-/**
- * Creates an oauth request and validates the id_token (if any)
- *
- * @method    create
- * @memberOf  module:auth.OAuthWithIDTokenValidation.prototype
- *
- * @param   {Object}    params            OAuth parameters that are passed through
- * @param   {Object}    data              Custom parameters sent to the OAuth endpoint
- * @param   {Function}  [callback]        Callback function
- *
- * @return  {Promise|undefined}
- */
-OAUthWithIDTokenValidation.prototype.create = function(params, data, cb) {
-  const createAndValidate = this.oauth.create(params, data).then(r => {
-    var _this = this;
-    if (r.id_token) {
-      function getKey(header, callback) {
-        if (header.alg === 'HS256') {
-          return callback(null, Buffer.from(_this.clientSecret, 'base64'));
+  /**
+   * Creates an oauth request and validates the id_token (if any)
+   *
+   * @param   {object}    params            OAuth parameters that are passed through
+   * @param   {object}    data              Custom parameters sent to the OAuth endpoint
+   * @param   {Function}  [cb]              Callback function
+   * @returns  {Promise|undefined}
+   */
+  create(params, data, cb) {
+    const _this = this;
+    function getKey(header, callback) {
+      if (header.alg === 'HS256') {
+        if (!_this.clientSecret) {
+          return callback({ message: HS256_IGNORE_VALIDATION_MESSAGE });
         }
-        _this._jwksClient.getSigningKey(header.kid, function(err, key) {
-          if (err) {
-            return callback(err);
-          }
-          var signingKey = key.publicKey || key.rsaPublicKey;
-          return callback(null, signingKey);
-        });
+        return callback(null, Buffer.from(_this.clientSecret, 'base64'));
+      }
+      _this._jwksClient.getSigningKey(header.kid, (err, key) => {
+        if (err) {
+          return callback(err);
+        }
+        const signingKey = key.publicKey || key.rsaPublicKey;
+        return callback(null, signingKey);
+      });
+    }
+    const createAndValidate = this.oauth.create(params, data).then((r) => {
+      if (_this.__bypassIdTokenValidation) {
+        return r;
       }
-      return new Promise((res, rej) => {
-        jwt.verify(
-          r.id_token,
-          getKey,
-          {
+
+      if (r.id_token) {
+        return new Promise((resolve, reject) => {
+          const options = {
             algorithms: this.supportedAlgorithms,
             audience: this.clientId,
-            issuer: 'https://' + this.domain + '/'
-          },
-          function(err, payload) {
+            issuer: `https://${this.domain}/`,
+          };
+
+          if (data.organization) {
+            options.organization = data.organization;
+          }
+
+          if (data.nonce) {
+            options.nonce = data.nonce;
+          }
+
+          if (data.maxAge) {
+            options.maxAge = data.maxAge;
+          }
+
+          jwt.verify(r.id_token, getKey, options, (err) => {
             if (err) {
-              return rej(err);
+              if (err.message && err.message.includes(HS256_IGNORE_VALIDATION_MESSAGE)) {
+                console.warn(HS256_IGNORE_VALIDATION_MESSAGE);
+              } else {
+                return reject(err);
+              }
             }
-            return res(r);
-          }
-        );
-      });
+
+            try {
+              validateIdToken(r.id_token, options);
+            } catch (idTokenError) {
+              return reject(idTokenError);
+            }
+
+            return resolve(r);
+          });
+        });
+      }
+      return r;
+    });
+    if (!cb) {
+      return createAndValidate;
     }
-    return r;
-  });
-  if (!cb) {
-    return createAndValidate;
+    createAndValidate.then((r) => cb(null, r)).catch((e) => cb(e));
   }
-  createAndValidate.then(r => cb(null, r)).catch(e => cb(e));
-};
+}
 
 module.exports = OAUthWithIDTokenValidation;
 
@@ -148,7 +176,7 @@

auth/OAUthWithIDTokenValidation.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/auth_OAuthAuthenticator.js.html b/docs/auth_OAuthAuthenticator.js.html index 31055ed63..1d058f36c 100644 --- a/docs/auth_OAuthAuthenticator.js.html +++ b/docs/auth_OAuthAuthenticator.js.html @@ -24,7 +24,8 @@
@@ -39,377 +40,395 @@

auth/OAuthAuthenticator.js

-
var extend = require('util')._extend;
-
-var ArgumentError = require('rest-facade').ArgumentError;
-var RestClient = require('rest-facade').Client;
-
-var OAUthWithIDTokenValidation = require('./OAUthWithIDTokenValidation');
+            
const { sanitizeArguments } = require('../utils');
+const { ArgumentError } = require('rest-facade');
+const RestClient = require('rest-facade').Client;
+const { SanitizedError } = require('../errors');
+const OAUthWithIDTokenValidation = require('./OAUthWithIDTokenValidation');
+
+function getParamsFromOptions(options) {
+  const params = {};
+  if (!options || typeof options !== 'object') {
+    return params;
+  }
+  if (options.forwardedFor) {
+    params._requestCustomizer = function (req) {
+      req.set('auth0-forwarded-for', options.forwardedFor);
+    };
+  }
+  if (options.type) {
+    params.type = options.type;
+  }
+  return params;
+}
 
 /**
- * @class
  * Abstracts the sign-in, sign-up and change-password processes for Database &
  * Active Directory authentication services.
- * @constructor
- * @memberOf module:auth
- *
- * @param  {Object}              options                Authenticator options.
- * @param  {String}              options.baseUrl        The Auth0 account URL.
- * @param  {String}              options.domain         AuthenticationClient server domain
- * @param  {String}              [options.clientId]     Default client ID.
- * @param  {String}              [options.clientSecret] Default client Secret.
  */
-var OAuthAuthenticator = function(options) {
-  if (!options) {
-    throw new ArgumentError('Missing authenticator options');
-  }
-
-  if (typeof options !== 'object') {
-    throw new ArgumentError('The authenticator options must be an object');
+class OAuthAuthenticator {
+  /**
+   * @param  {object}              options                             Authenticator options.
+   * @param  {string}              options.baseUrl                     The Auth0 account URL.
+   * @param  {string}              options.domain                      AuthenticationClient server domain
+   * @param  {string}              [options.clientId]                  Default client ID.
+   * @param  {string}              [options.clientSecret]              Default client Secret.
+   * @param  {boolean}             [options.__bypassIdTokenValidation] Whether the id_token should be validated or not
+   */
+  constructor(options) {
+    if (!options) {
+      throw new ArgumentError('Missing authenticator options');
+    }
+
+    if (typeof options !== 'object') {
+      throw new ArgumentError('The authenticator options must be an object');
+    }
+
+    /**
+     * Options object for the Rest Client instance.
+     *
+     * @type {object}
+     */
+    const clientOptions = {
+      errorCustomizer: SanitizedError,
+      errorFormatter: { message: 'message', name: 'error' },
+      headers: options.headers,
+    };
+
+    this.oauth = new RestClient(`${options.baseUrl}/oauth/:type`, clientOptions);
+    this.oauthWithIDTokenValidation = new OAUthWithIDTokenValidation(this.oauth, options);
+    this.clientId = options.clientId;
+    this.clientSecret = options.clientSecret;
   }
 
   /**
-   * Options object for the Rest Client instace.
+   * Sign in using a username and password.
+   *
+   * @example <caption>
+   *   Given the user's credentials and the connection specified, it
+   *   will return a JSON with the access_token and id_token.
+   *   More information in the
    *
-   * @type {Object}
+   *   <a href="https://auth0.com/docs/api/authentication#database-ad-ldap-active-">
+   *     API Docs
+   *   </a>.
+   * </caption>
+   *
+   * var data = {
+   *   client_id: '{CLIENT_ID}',  // Optional field.
+   *   username: '{USERNAME}',
+   *   password: '{PASSWORD}',
+   *   connection: '{CONNECTION_NAME}',
+   *   scope: 'openid'  // Optional field.
+   * };
+   *
+   * auth0.oauth.signIn(data, function (err, userData) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(userData);
+   * });
+   * @param   {object}    userData               User credentials object.
+   * @param   {string}    userData.username      Username.
+   * @param   {string}    userData.password      User password.
+   * @param   {string}    userData.connection    The identity provider in use.
+   * @param   {object}    [options]              Additional options.
+   * @param   {string}    [options.forwardedFor] Value to be used for auth0-forwarded-for header
+   * @param {Function} cb                        Callback
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' }
-  };
-
-  this.oauth = new RestClient(options.baseUrl + '/oauth/:type', clientOptions);
-  this.oauthWithIDTokenValidation = new OAUthWithIDTokenValidation(this.oauth, options);
-  this.clientId = options.clientId;
-  this.clientSecret = options.clientSecret;
-};
-
-/**
- * Sign in using a username and password.
- *
- * @method    signIn
- * @memberOf  module:auth.OAuthAuthenticator.prototype
- *
- * @example <caption>
- *   Given the user's credentials and the connection specified, it
- *   will return a JSON with the access_token and id_token.
- *   More information in the
- *   <a href="https://auth0.com/docs/api/authentication#database-ad-ldap-active-">
- *     API Docs
- *   </a>.
- * </caption>
- *
- * var data = {
- *   client_id: '{CLIENT_ID}',  // Optional field.
- *   username: '{USERNAME}',
- *   password: '{PASSWORD}',
- *   connection: '{CONNECTION_NAME}',
- *   scope: 'openid'  // Optional field.
- * };
- *
- * auth0.oauth.signIn(data, function (err, userData) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(userData);
- * });
- *
- * @param   {Object}    userData              User credentials object.
- * @param   {String}    userData.username     Username.
- * @param   {String}    userData.password     User password.
- * @param   {String}    userData.connection   The identity provider in use.
- *
- * @return  {Promise|undefined}
- */
-OAuthAuthenticator.prototype.signIn = function(userData, cb) {
-  var params = {
-    type: 'ro'
-  };
-  var defaultFields = {
-    client_id: this.clientId,
-    grant_type: 'password',
-    scope: 'openid'
-  };
-  var data = extend(defaultFields, userData);
-
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
-
-  if (typeof data.connection !== 'string' || data.connection.split().length === 0) {
-    throw new ArgumentError('connection field is required');
-  }
-
-  if (cb && cb instanceof Function) {
-    return this.oauthWithIDTokenValidation.create(params, data, cb);
-  }
-
-  return this.oauthWithIDTokenValidation.create(params, data);
-};
-
-/**
- * Sign in using a username and password
- *
- * @method    passwordGrant
- * @memberOf  module:auth.OAuthAuthenticator.prototype
- *
- * @example <caption>
- *   Given the user's credentials perform the OAuth password grant
- *   or Password Realm grant if a realm is provided,
- *   it will return a JSON with the access_token and id_token.
- *   More information in the
- *   <a href="https://auth0.com/docs/api/authentication#resource-owner-password">
- *     API Docs
- *   </a>.
- * </caption>
- *
- * var data = {
- *   client_id: '{CLIENT_ID}',  // Optional field.
- *   username: '{USERNAME}',
- *   password: '{PASSWORD}',
- *   realm: '{CONNECTION_NAME}', // Optional field.
- *   scope: 'openid'  // Optional field.
- * };
- *
- * auth0.oauth.passwordGrant(data, function (err, userData) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(userData);
- * });
- *
- * @param   {Object}    userData              User credentials object.
- * @param   {String}    userData.username     Username.
- * @param   {String}    userData.password     User password.
- * @param   {String}    [userData.realm]      Name of the realm to use to authenticate or the connection name
- *
- * @return  {Promise|undefined}
- */
-OAuthAuthenticator.prototype.passwordGrant = function(userData, cb) {
-  var params = {
-    type: 'token'
-  };
-  var defaultFields = {
-    client_id: this.clientId,
-    client_secret: this.clientSecret,
-    grant_type: 'password'
-  };
-  var data = extend(defaultFields, userData);
-
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
-
-  if (typeof data.username !== 'string' || data.username.split().length === 0) {
-    throw new ArgumentError('username field is required');
-  }
-
-  if (typeof data.password !== 'string' || data.password.split().length === 0) {
-    throw new ArgumentError('password field is required');
-  }
-
-  if (typeof data.realm === 'string' && data.realm.split().length !== 0) {
-    data.grant_type = 'http://auth0.com/oauth/grant-type/password-realm';
-  }
-
-  if (cb && cb instanceof Function) {
-    return this.oauthWithIDTokenValidation.create(params, data, cb);
-  }
-
-  return this.oauthWithIDTokenValidation.create(params, data);
-};
-
-/**
- * Sign in using a refresh token
- *
- * @method    refreshToken
- * @memberOf  module:auth.OAuthAuthenticator.prototype
- *
- * @example <caption>
- *   Given a refresh token from a previous authentication request
- *   it will return a JSON with the access_token and id_token.
- *   More information in the
- *   <a href="https://auth0.com/docs/api/authentication#refresh-token">
- *     API Docs
- *   </a>.
- * </caption>
- *
- * var data = {
- *   client_id: '{CLIENT_ID}', // Optional field.
- *   refresh_token: '{REFRESH_TOKEN}',
- * };
- *
- * auth0.oauth.refreshToken(data, function (err, userData) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(userData);
- * });
- *
- * @param   {Object}    userData                User credentials object.
- * @param   {String}    userData.refresh_token  Refresh token.
- *
- * @return  {Promise|undefined}
- */
-OAuthAuthenticator.prototype.refreshToken = function(userData, cb) {
-  var params = {
-    type: 'token'
-  };
-  var defaultFields = {
-    client_id: this.clientId,
-    grant_type: 'refresh_token'
-  };
-  var data = extend(defaultFields, userData);
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
-  if (typeof data.refresh_token !== 'string' || data.refresh_token.split().length === 0) {
-    throw new ArgumentError('refresh_token is required');
-  }
-  if (cb && cb instanceof Function) {
-    return this.oauthWithIDTokenValidation.create(params, data, cb);
+  signIn(userData, options, cb) {
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
+
+    const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb);
+    const params = {
+      type: 'ro',
+      ...getParamsFromOptions(sanitizedOptions),
+    };
+
+    const data = {
+      client_id: this.clientId,
+      grant_type: 'password',
+      scope: 'openid',
+      ...userData,
+    };
+
+    if (
+      params.type === 'ro' &&
+      (typeof data.connection !== 'string' || data.connection.split().length === 0)
+    ) {
+      throw new ArgumentError('connection field is required');
+    }
+
+    if (sanitizedCb && sanitizedCb instanceof Function) {
+      return this.oauthWithIDTokenValidation.create(params, data, sanitizedCb);
+    }
+
+    return this.oauthWithIDTokenValidation.create(params, data);
   }
-  return this.oauthWithIDTokenValidation.create(params, data);
-};
 
-/**
- * Sign in using a social provider access token.
- *
- * @method    socialSignIn
- * @memberOf  module:auth.OAuthAuthenticator.prototype
- *
- * @param   {Object}    data                User credentials object.
- * @param   {String}    data.access_token   User access token.
- * @param   {String}    data.connection     Identity provider.
- *
- * @return  {Promise|undefined}
- */
-OAuthAuthenticator.prototype.socialSignIn = function(data, cb) {
-  var params = {
-    type: 'access_token'
-  };
-
-  if (typeof data !== 'object') {
-    throw new ArgumentError('Missing user credential objects');
-  }
-
-  if (typeof data.access_token !== 'string' || data.access_token.trim().length === 0) {
-    throw new ArgumentError('access_token field is required');
-  }
-
-  if (typeof data.connection !== 'string' || data.connection.trim().length === 0) {
-    throw new ArgumentError('connection field is required');
+  /**
+   * Sign in using a username and password
+   *
+   * @example <caption>
+   *   Given the user's credentials perform the OAuth password grant
+   *   or Password Realm grant if a realm is provided,
+   *   it will return a JSON with the access_token and id_token.
+   *
+   *   More information in the
+   *   <a href="https://auth0.com/docs/api/authentication#resource-owner-password">
+   *     API Docs
+   *   </a>.
+   * </caption>
+   *
+   * var data = {
+   *   client_id: '{CLIENT_ID}',  // Optional field.
+   *   username: '{USERNAME}',
+   *   password: '{PASSWORD}',
+   *   realm: '{CONNECTION_NAME}', // Optional field.
+   *   scope: 'openid'  // Optional field.
+   * };
+   *
+   * auth0.oauth.passwordGrant(data, function (err, userData) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(userData);
+   * });
+   * @param   {object}    userData               User credentials object.
+   * @param   {string}    userData.username      Username.
+   * @param   {string}    userData.password      User password.
+   * @param   {string}    [userData.realm]       Name of the realm to use to authenticate or the connection name
+   * @param   {object}    [options]              Additional options.
+   * @param   {string}    [options.forwardedFor] Value to be used for auth0-forwarded-for header
+   * @param {Function} cb                        Callback
+   * @returns  {Promise|undefined}
+   */
+  passwordGrant(userData, options, cb) {
+    const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb);
+
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
+
+    const data = {
+      client_id: this.clientId,
+      client_secret: this.clientSecret,
+      grant_type: 'password',
+      ...userData,
+    };
+
+    if (typeof data.username !== 'string' || data.username.split().length === 0) {
+      throw new ArgumentError('username field is required');
+    }
+
+    if (typeof data.password !== 'string' || data.password.split().length === 0) {
+      throw new ArgumentError('password field is required');
+    }
+
+    if (typeof data.realm === 'string' && data.realm.split().length !== 0) {
+      data.grant_type = 'http://auth0.com/oauth/grant-type/password-realm';
+    }
+
+    const params = {
+      type: 'token',
+      ...getParamsFromOptions(sanitizedOptions),
+    };
+
+    if (sanitizedCb && sanitizedCb instanceof Function) {
+      return this.oauthWithIDTokenValidation.create(params, data, sanitizedCb);
+    }
+
+    return this.oauthWithIDTokenValidation.create(params, data);
   }
 
-  if (cb && cb instanceof Function) {
-    return this.oauth.create(params, data, cb);
+  /**
+   * Exchange a refresh token
+   *
+   * @example <caption>
+   *   Given a refresh token from a previous authentication request
+   *   it will return a JSON with the access_token and id_token if
+   *   the openid scope was originally included.
+   *   More information in the
+   *   <a href="https://auth0.com/docs/api/authentication#refresh-token">
+   *     API Docs
+   *   </a>.
+   * </caption>
+   *
+   * var data = {
+   *   refresh_token: '{REFRESH_TOKEN}',
+   * };
+   *
+   * auth0.oauth.refreshToken(data, function (err, data) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(data);
+   * });
+   * @param   {object}    data                Data object.
+   * @param   {string}    data.refresh_token  Refresh token.
+   * @param  {Function}  cb Callback
+   * @returns  {Promise|undefined}
+   */
+  refreshToken(data, cb) {
+    if (!data || typeof data !== 'object') {
+      throw new ArgumentError('Missing data object');
+    }
+
+    data = {
+      client_id: this.clientId,
+      client_secret: this.clientSecret,
+      grant_type: 'refresh_token',
+      ...data,
+    };
+
+    if (typeof data.refresh_token !== 'string' || data.refresh_token.split().length === 0) {
+      throw new ArgumentError('refresh_token is required');
+    }
+
+    const params = {
+      type: 'token',
+    };
+
+    if (cb && cb instanceof Function) {
+      return this.oauth.create(params, data, cb);
+    }
+    return this.oauth.create(params, data);
   }
 
-  return this.oauth.create(params, data);
-};
-
-OAuthAuthenticator.prototype.clientCredentialsGrant = function(options, cb) {
-  var params = {
-    type: 'token'
-  };
-
-  var defaultFields = {
-    grant_type: 'client_credentials',
-    client_id: this.clientId,
-    client_secret: this.clientSecret
-  };
+  /**
+   * Sign in using a social provider access token.
+   *
+   * @param   {object}    data                User credentials object.
+   * @param   {string}    data.access_token   User access token.
+   * @param   {string}    data.connection     Identity provider.
+   * @param   {Function}    cb     Callback
+   * @returns  {Promise|undefined}
+   */
+  socialSignIn(data, cb) {
+    const params = {
+      type: 'access_token',
+    };
 
-  var data = extend(defaultFields, options);
+    if (typeof data !== 'object') {
+      throw new ArgumentError('Missing user credential objects');
+    }
 
-  if (!options || typeof options !== 'object') {
-    throw new ArgumentError('Missing options object');
-  }
+    if (typeof data.access_token !== 'string' || data.access_token.trim().length === 0) {
+      throw new ArgumentError('access_token field is required');
+    }
 
-  if (!data.client_id || data.client_id.trim().length === 0) {
-    throw new ArgumentError('client_id field is required');
-  }
+    if (typeof data.connection !== 'string' || data.connection.trim().length === 0) {
+      throw new ArgumentError('connection field is required');
+    }
 
-  if (!data.client_secret || data.client_secret.trim().length === 0) {
-    throw new ArgumentError('client_secret field is required');
-  }
+    if (cb && cb instanceof Function) {
+      return this.oauth.create(params, data, cb);
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.oauth.create(params, data, cb);
+    return this.oauth.create(params, data);
   }
 
-  return this.oauth.create(params, data);
-};
+  clientCredentialsGrant(options, cb) {
+    if (!options || typeof options !== 'object') {
+      throw new ArgumentError('Missing options object');
+    }
 
-/**
- * Sign in using an authorization code
- *
- * @method    authorizationCodeGrant
- * @memberOf  module:auth.OAuthAuthenticator.prototype
- *
- * @example <caption>
- *   Given the code returned in the URL params after the redirect
- *   from successful authentication, exchange the code for auth0
- *   credentials. It will return JSON with the access_token and id_token.
- *   More information in the
- *   <a href="https://auth0.com/docs/api/authentication#authorization-code-grant">
- *     API Docs
- *   </a>.
- * </caption>
- *
- * var data = {
- *   code: '{CODE}',
- *   redirect_uri: '{REDIRECT_URI}',
- *   client_id: '{CLIENT_ID}',  // Optional field.
- *   client_secret: '{CLIENT_SECRET}',  // Optional field.
- * };
- *
- * auth0.oauth.authorizationCodeGrant(data, function (err, userData) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(userData);
- * });
- *
- * @param   {Object}    data                  Authorization code payload
- * @param   {String}    userData.code         Code in URL returned after authentication
- * @param   {String}    userData.redirect_uri The URL to which Auth0 will redirect the browser after authorization has been granted by the user.
- *
- * @return  {Promise|undefined}
- */
-OAuthAuthenticator.prototype.authorizationCodeGrant = function(options, cb) {
-  var params = {
-    type: 'token'
-  };
+    const data = {
+      grant_type: 'client_credentials',
+      client_id: this.clientId,
+      client_secret: this.clientSecret,
+      ...options,
+    };
 
-  var defaultFields = {
-    grant_type: 'authorization_code',
-    client_id: this.clientId,
-    client_secret: this.clientSecret
-  };
+    if (!data.client_id || data.client_id.trim().length === 0) {
+      throw new ArgumentError('client_id field is required');
+    }
 
-  var data = extend(defaultFields, options);
+    if (!data.client_secret || data.client_secret.trim().length === 0) {
+      throw new ArgumentError('client_secret field is required');
+    }
 
-  if (!options || typeof options !== 'object') {
-    throw new ArgumentError('Missing options object');
-  }
+    const params = {
+      type: 'token',
+    };
 
-  if (!data.code || data.code.trim().length === 0) {
-    throw new ArgumentError('code field is required');
-  }
+    if (cb && cb instanceof Function) {
+      return this.oauth.create(params, data, cb);
+    }
 
-  if (!data.redirect_uri || data.redirect_uri.trim().length === 0) {
-    throw new ArgumentError('redirect_uri field is required');
+    return this.oauth.create(params, data);
   }
 
-  if (cb && cb instanceof Function) {
-    return this.oauthWithIDTokenValidation.create(params, data, cb);
+  /**
+   * Sign in using an authorization code
+   *
+   * @example <caption>
+   *   Given the code returned in the URL params after the redirect
+   *   from successful authentication, exchange the code for auth0
+   *   credentials. It will return JSON with the access_token and id_token.
+   *   More information in the
+   *   <a href="https://auth0.com/docs/api/authentication#authorization-code-grant">
+   *     API Docs
+   *   </a>.
+   * </caption>
+   *
+   * var options = {
+   *   code: '{CODE}',
+   *   redirect_uri: '{REDIRECT_URI}',
+   *   organization: '{ORGANIZATION_ID}' // Optiional field.
+   * };
+   *
+   * auth0.oauth.authorizationCodeGrant(options, function (err, userData) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(userData);
+   * });
+   * @param   {object}    options                  Authorization code payload
+   * @param   {string}    options.organization     Organization ID
+   * @param   {string}    options.code             Code in URL returned after authentication
+   * @param   {string}    options.redirect_uri     The URL to which Auth0 will redirect the browser after authorization has been granted by the user.
+   * @param {Function} cb Callback
+   * @returns  {Promise|undefined}
+   */
+  authorizationCodeGrant(options, cb) {
+    if (!options || typeof options !== 'object') {
+      throw new ArgumentError('Missing options object');
+    }
+
+    const data = {
+      grant_type: 'authorization_code',
+      client_id: this.clientId,
+      client_secret: this.clientSecret,
+      ...options,
+    };
+
+    if (!data.code || data.code.trim().length === 0) {
+      throw new ArgumentError('code field is required');
+    }
+
+    if (!data.redirect_uri || data.redirect_uri.trim().length === 0) {
+      throw new ArgumentError('redirect_uri field is required');
+    }
+
+    const params = {
+      type: 'token',
+    };
+
+    if (cb && cb instanceof Function) {
+      return this.oauthWithIDTokenValidation.create(params, data, cb);
+    }
+
+    return this.oauthWithIDTokenValidation.create(params, data);
   }
-
-  return this.oauthWithIDTokenValidation.create(params, data);
-};
+}
 
 module.exports = OAuthAuthenticator;
 
@@ -424,7 +443,7 @@

auth/OAuthAuthenticator.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/auth_PasswordlessAuthenticator.js.html b/docs/auth_PasswordlessAuthenticator.js.html index 49e45b1be..9c1f3f2ea 100644 --- a/docs/auth_PasswordlessAuthenticator.js.html +++ b/docs/auth_PasswordlessAuthenticator.js.html @@ -24,7 +24,8 @@
@@ -39,239 +40,290 @@

auth/PasswordlessAuthenticator.js

-
var extend = require('util')._extend;
-
-var ArgumentError = require('rest-facade').ArgumentError;
-var RestClient = require('rest-facade').Client;
+            
const { ArgumentError } = require('rest-facade');
+const RestClient = require('rest-facade').Client;
+const { sanitizeArguments } = require('../utils');
+
+function getParamsFromOptions(options) {
+  const params = {};
+  if (!options || typeof options !== 'object') {
+    return params;
+  }
+  if (options.forwardedFor) {
+    params._requestCustomizer = function (req) {
+      req.set('auth0-forwarded-for', options.forwardedFor);
+    };
+  }
+  return params;
+}
 
 /**
- * @class
  * Handles authenticator with passwordless flows, e.g. SMS, Touch ID, etc.
- * @constructor
- * @memberOf module:auth
- *
- * @param  {Object}              options            Authenticator options.
- * @param  {String}              options.baseUrl    The auth0 account URL.
- * @param  {String}              [options.clientId] Default client ID.
- * @param  {OAuthAuthenticator}  oauth              OAuthAuthenticator instance.
  */
-var PasswordlessAuthenticator = function(options, oauth) {
-  if (!options) {
-    throw new ArgumentError('Missing authenticator options');
-  }
 
-  if (typeof options !== 'object') {
-    throw new ArgumentError('The authenticator options must be an object');
+class PasswordlessAuthenticator {
+  /**
+   * @param  {object}              options            Authenticator options.
+   * @param  {string}              options.baseUrl    The auth0 account URL.
+   * @param  {string}              [options.clientId] Default client ID.
+   * @param  {string}              [options.clientSecret] Default client secret.
+   * @param  {OAuthAuthenticator}  oauth              OAuthAuthenticator instance.
+   */
+  constructor(options, oauth) {
+    if (!options) {
+      throw new ArgumentError('Missing authenticator options');
+    }
+
+    if (typeof options !== 'object') {
+      throw new ArgumentError('The authenticator options must be an object');
+    }
+
+    /**
+     * Options object for the Rest Client instance.
+     *
+     * @type {object}
+     */
+    const clientOptions = {
+      errorFormatter: { message: 'message', name: 'error' },
+      headers: options.headers,
+    };
+
+    this.oauth = oauth;
+    this.passwordless = new RestClient(`${options.baseUrl}/passwordless/start`, clientOptions);
+    this.clientId = options.clientId;
+    this.clientSecret = options.clientSecret;
   }
 
   /**
-   * Options object for the Rest Client instace.
+   * Sign in with the given user credentials.
+   *
+   * @example <caption>
+   * Once you have a verification code, use this endpoint to login
+   * the user with their phone number/email and verification code.
    *
-   * @type {Object}
+   * https://auth0.com/docs/api/authentication#authenticate-user
+   * </caption>
+   *
+   * var data = {
+   *   username: '{PHONE_NUMBER OR EMAIL}',
+   *   otp: '{VERIFICATION_CODE}',
+   *   realm: '{sms or email}' // OPTIONAL DEFAULTS TO SMS
+   * };
+   *
+   * auth0.passwordless.signIn(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @example <caption>
+   *   The user data object has the following structure.
+   * </caption>
+   *
+   * {
+   *   id_token: String,
+   *   access_token: String,
+   *   token_type: String
+   * }
+   * @example <caption>
+   *  LEGACY signIn using the `/oauth/ro` endpoint. When otp is not specified
+   *  password is required. Given the user credentials (`phone_number` and `code`),
+   *  it will do the authentication on the provider and return a JSON with
+   *  the `access_token` and `id_token`.
+   *
+   * https://auth0.com/docs/api/authentication#resource-owner
+   * </caption>
+   *
+   * var data = {
+   *   username: '{PHONE_NUMBER}',
+   *   password: '{VERIFICATION_CODE}'
+   * };
+   *
+   * auth0.passwordless.signIn(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    userData              User credentials object.
+   * @param   {string}    userData.username     The user's phone number if realm=sms, or the user's email if realm=email
+   * @param   {string}    userData.otp        The user's verification code. Required
+   * @param   {string}    [userData.audience]     API Identifier of the API for which you want to get an Access Token.
+   * @param   {string}    [userData.realm=sms]  Realm string: "sms" or "email".
+   * @param   {string}    [userData.password]     [DEPRECATED] Password required if using legacy /oauth/ro endpoint
+   * @param   {string}    [userData.connection=sms] [DEPRECATED] Connection string: "sms" or "email".
+   * @param   {object}    [options]              Additional options.
+   * @param   {string}    [options.forwardedFor] Value to be used for auth0-forwarded-for header
+   * @param   {Function}  [cb]                  Method callback.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' }
-  };
-
-  this.oauth = oauth;
-  this.passwordless = new RestClient(options.baseUrl + '/passwordless/start', clientOptions);
-  this.clientId = options.clientId;
-};
-
-/**
- * Sign in with the given user credentials.
- *
- * @method    signIn
- * @memberOf  module:auth.PasswordlessAuthenticator.prototype
- * @example <caption>
- *   Given the user credentials (`phone_number` and `code`), it will do the
- *   authentication on the provider and return a JSON with the `access_token`
- *   and `id_token`.
- * </caption>
- *
- * var data = {
- *   username: '{PHONE_NUMBER}',
- *   password: '{VERIFICATION_CODE}'
- * };
- *
- * auth0.passwordless.signIn(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- * });
- *
- * @example <caption>
- *   The user data object has the following structure.
- * </caption>
- *
- * {
- *   id_token: String,
- *   access_token: String,
- *   token_type: String
- * }
- *
- * @param   {Object}    userData              User credentials object.
- * @param   {String}    userData.username     Username.
- * @param   {String}    userData.password     Password.
- * @param   {String}    [userData.connection=sms]  Connection string: "sms" or "email".
- * @param   {String}    [userData.client_id]  Client ID.
- * @param   {Function}  [cb]                  Method callback.
- *
- * @return  {Promise|undefined}
- */
-PasswordlessAuthenticator.prototype.signIn = function(userData, cb) {
-  var defaultFields = {
-    client_id: this.clientId
-  };
-  var data = extend(defaultFields, userData);
-
-  // Don't let the user override the connection nor the grant type.
-  if (!data.connection || (data.connection !== 'email' && data.connection !== 'sms')) {
-    data.connection = 'sms';
-  }
-  data.grant_type = 'password';
-
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
-
-  if (typeof data.username !== 'string' || data.username.trim().length === 0) {
-    throw new ArgumentError('username field (phone number) is required');
-  }
-
-  if (typeof data.password !== 'string' || data.password.trim().length === 0) {
-    throw new ArgumentError('password field (verification code) is required');
-  }
-
-  return this.oauth.signIn(data, cb);
-};
-
-/**
- * Start passwordless flow sending an email.
- *
- * @method    sendEmail
- * @memberOf  module:auth.PasswordlessAuthenticator.prototype
- * @example <caption>
- *   Given the user `email` address, it will send an email with:
- *
- *   <ul>
- *     <li>A link (default, `send:"link"`). You can then authenticate with this
- *       user opening the link and he will be automatically logged in to the
- *       application. Optionally, you can append/override parameters to the link
- *       (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using
- *       `authParams` object.
- *     </li>
- *     <li>
- *       A verification code (`send:"code"`). You can then authenticate with
- *       this user using the `/oauth/ro` endpoint specifying `email` as
- *       `username` and `code` as `password`.
- *     </li>
- *   </ul>
- *
- *   Find more information in the
- *   <a href="https://auth0.com/docs/auth-api#!#post--with_email">API Docs</a>
- * </caption>
- *
- * var data = {
- *   email: '{EMAIL}',
- *   send: 'link',
- *   authParams: {} // Optional auth params.
- * };
- *
- * auth0.passwordless.sendEmail(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- * });
- *
- * @param   {Object}    userData                User account data.
- * @param   {String}    userData.email          User email address.
- * @param   {String}    userData.send           The type of email to be sent.
- * @param   {Function}  [cb]                    Method callback.
- *
- * @return  {Promise|undefined}
- */
-PasswordlessAuthenticator.prototype.sendEmail = function(userData, cb) {
-  var defaultFields = {
-    client_id: this.clientId
-  };
-  var data = extend(defaultFields, userData);
-
-  // Don't let the user override the connection nor the grant type.
-  data.connection = 'email';
-
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
-
-  if (typeof data.email !== 'string' || data.email.trim().length === 0) {
-    throw new ArgumentError('email field is required');
-  }
-
-  if (typeof data.send !== 'string' || data.send.trim().length === 0) {
-    throw new ArgumentError('send field is required');
+  signIn(userData, options, cb) {
+    const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb);
+
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
+
+    const data = {
+      client_id: this.clientId,
+      client_secret: this.clientSecret,
+      ...userData,
+    };
+
+    if (typeof data.username !== 'string' || data.username.trim().length === 0) {
+      throw new ArgumentError('username field (phone number) is required');
+    }
+
+    // If otp is provided, attempt to sign in using otp grant
+    if (typeof data.otp === 'string' && data.otp.trim().length > 0) {
+      if (!data.realm || (data.realm !== 'email' && data.realm !== 'sms')) {
+        data.realm = 'sms';
+      }
+      data.grant_type = 'http://auth0.com/oauth/grant-type/passwordless/otp';
+      return this.oauth.signIn(data, { type: 'token', ...sanitizedOptions }, sanitizedCb);
+    }
+
+    // Don't let the user override the connection nor the grant type.
+    if (!data.connection || (data.connection !== 'email' && data.connection !== 'sms')) {
+      data.connection = 'sms';
+    }
+    data.grant_type = 'password';
+
+    if (typeof data.password !== 'string' || data.password.trim().length === 0) {
+      throw new ArgumentError('password field (verification code) is required');
+    }
+
+    console.warn(
+      'The oauth/ro endpoint has been deprecated. Please use the realm and otp parameters in this function.'
+    );
+    return this.oauth.signIn(data, sanitizedOptions, sanitizedCb);
   }
 
-  if (cb && cb instanceof Function) {
-    return this.passwordless.create(data, cb);
+  /**
+   * Start passwordless flow sending an email.
+   *
+   * @example <caption>
+   *   Given the user `email` address, it will send an email with:
+   *
+   *   <ul>
+   *     <li>A link (default, `send:"link"`). You can then authenticate with this
+   *       user opening the link and he will be automatically logged in to the
+   *       application. Optionally, you can append/override parameters to the link
+   *       (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using
+   *       `authParams` object.
+   *     </li>
+   *     <li>
+   *       A verification code (`send:"code"`). You can then authenticate with
+   *       this user using the `/oauth/ro` endpoint specifying `email` as
+   *       `username` and `code` as `password`.
+   *     </li>
+   *   </ul>
+   *
+   *   Find more information in the
+   *   <a href="https://auth0.com/docs/auth-api#!#post--with_email">API Docs</a>
+   * </caption>
+   *
+   * var data = {
+   *   email: '{EMAIL}',
+   *   send: 'link',
+   *   authParams: {} // Optional auth params.
+   * };
+   *
+   * auth0.passwordless.sendEmail(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    userData                User account data.
+   * @param   {string}    userData.email          User email address.
+   * @param   {string}    userData.send           The type of email to be sent.
+   * @param   {object}    [options]              Additional options.
+   * @param   {string}    [options.forwardedFor] Value to be used for auth0-forwarded-for header
+   * @param   {Function}  [cb]                    Method callback.
+   * @returns  {Promise|undefined}
+   */
+  sendEmail(userData, options, cb) {
+    const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb);
+    const data = {
+      client_id: this.clientId,
+      client_secret: this.clientSecret,
+      ...userData,
+    };
+    const params = getParamsFromOptions(sanitizedOptions);
+
+    // Don't let the user override the connection nor the grant type.
+    data.connection = 'email';
+
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
+
+    if (typeof data.email !== 'string' || data.email.trim().length === 0) {
+      throw new ArgumentError('email field is required');
+    }
+
+    if (typeof data.send !== 'string' || data.send.trim().length === 0) {
+      throw new ArgumentError('send field is required');
+    }
+
+    if (sanitizedCb && sanitizedCb instanceof Function) {
+      return this.passwordless.create(params, data, sanitizedCb);
+    }
+
+    return this.passwordless.create(params, data);
   }
 
-  return this.passwordless.create(data);
-};
-
-/**
- * Start passwordless flow sending an SMS.
- *
- * @method    sendSMS
- * @memberOf  module:auth.PasswordlessAuthenticator.prototype
- *
- * @example <caption>
- *   Given the user `phone_number`, it will send a SMS message with a
- *   verification code. You can then authenticate with this user using the
- *   `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as
- *   `password`:
- * </caption>
- *
- * var data = {
- *   phone_number: '{PHONE}'
- * };
- *
- * auth0.passwordless.sendSMS(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- * });
- *
- * @param   {Object}    userData                User account data.
- * @param   {String}    userData.phone_number   User phone number.
- * @param   {String}    [userData.client_id]    Client ID.
- * @param   {Function}  [cb]                    Method callback.
- *
- * @return  {Promise|undefined}
- */
-PasswordlessAuthenticator.prototype.sendSMS = function(userData, cb) {
-  var defaultFields = {
-    client_id: this.clientId
-  };
-  var data = extend(defaultFields, userData);
+  /**
+   * Start passwordless flow sending an SMS.
+   *
+   * @example <caption>
+   *   Given the user `phone_number`, it will send a SMS message with a
+   *   verification code. You can then authenticate with this user using the
+   *   `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as
+   *   `password`:
+   * </caption>
+   *
+   * var data = {
+   *   phone_number: '{PHONE}'
+   * };
+   *
+   * auth0.passwordless.sendSMS(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    userData                User account data.
+   * @param   {string}    userData.phone_number   User phone number.
+   * @param   {object}    [options]              Additional options.
+   * @param   {string}    [options.forwardedFor] Value to be used for auth0-forwarded-for header
+   * @param   {Function}  [cb]                    Method callback.
+   * @returns  {Promise|undefined}
+   */
+  sendSMS(userData, options, cb) {
+    const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb);
+    const data = {
+      client_id: this.clientId,
+      client_secret: this.clientSecret,
+      ...userData,
+    };
+    const params = getParamsFromOptions(sanitizedOptions);
+
+    // Don't let the user override the connection nor the grant type.
+    data.connection = 'sms';
 
-  // Don't let the user override the connection nor the grant type.
-  data.connection = 'sms';
+    if (!userData || typeof userData !== 'object') {
+      throw new ArgumentError('Missing user data object');
+    }
 
-  if (!userData || typeof userData !== 'object') {
-    throw new ArgumentError('Missing user data object');
-  }
+    if (typeof data.phone_number !== 'string' || data.phone_number.trim().length === 0) {
+      throw new ArgumentError('phone_number field is required');
+    }
 
-  if (typeof data.phone_number !== 'string' || data.phone_number.trim().length === 0) {
-    throw new ArgumentError('phone_number field is required');
-  }
+    if (sanitizedCb && sanitizedCb instanceof Function) {
+      return this.passwordless.create(params, data, sanitizedCb);
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.passwordless.create(data, cb);
+    return this.passwordless.create(params, data);
   }
-
-  return this.passwordless.create(data);
-};
+}
 
 module.exports = PasswordlessAuthenticator;
 
@@ -286,7 +338,7 @@

auth/PasswordlessAuthenticator.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/auth_TokensManager.js.html b/docs/auth_TokensManager.js.html index dab714d38..eed9b6234 100644 --- a/docs/auth_TokensManager.js.html +++ b/docs/auth_TokensManager.js.html @@ -24,7 +24,8 @@
@@ -39,179 +40,246 @@

auth/TokensManager.js

-
var extend = require('util')._extend;
-var getRequestPromise = require('../utils').getRequestPromise;
-
-var ArgumentError = require('rest-facade').ArgumentError;
+            
const axios = require('axios');
+const { ArgumentError } = require('rest-facade');
 
 /**
- * @class
  * Provides methods for getting token data and exchanging tokens.
- * @constructor
- * @memberOf module:auth
- *
- * @param  {Object}   options               Manager options.
- * @param  {String}   options.baseUrl       The auth0 account URL.
- * @param  {String}   [options.headers]     Default request headers.
- * @param  {String}   [options.clientId]    Default client ID.
- */
-var TokensManager = function(options) {
-  if (typeof options !== 'object') {
-    throw new ArgumentError('Missing tokens manager options');
-  }
-
-  if (typeof options.baseUrl !== 'string') {
-    throw new ArgumentError('baseUrl field is required');
-  }
-
-  this.baseUrl = options.baseUrl;
-  this.headers = options.headers || {};
-  this.clientId = options.clientId || '';
-};
-
-/**
- * Given an ID token get the user profile linked to it.
- *
- * @method
- * @memberOf module:auth.TokensManager.prototype
- *
- * @example <caption>
- *   Validates a JSON Web Token (signature and expiration) and returns the user
- *   information associated with the user id (sub property) of the token. Find
- *   more information in the
- *   <a href="https://auth0.com/docs/auth-api#!#post--tokeninfo">API Docs</a>.
- * </caption>
- *
- * auth0.tokens.getInfo(token, function (err, tokenInfo) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(tokenInfo);
- * });
- *
- * @param   {String}    idToken     User ID token.
- * @param   {Function}  [cb]        Method callback.
- *
- * @return  {Promise|undefined}
- */
-TokensManager.prototype.getInfo = function(idToken, cb) {
-  var headers = extend({}, this.headers);
-
-  if (idToken === null || idToken === undefined) {
-    throw new ArgumentError('An ID token is required');
-  }
-
-  if (typeof idToken !== 'string' || idToken.trim().length === 0) {
-    throw new ArgumentError('The ID token is not valid');
-  }
-
-  // Perform the request.
-  var promise = getRequestPromise({
-    method: 'POST',
-    url: this.baseUrl + '/tokeninfo',
-    data: { id_token: idToken },
-    headers: headers
-  });
-
-  // Use callback if given.
-  if (cb instanceof Function) {
-    promise.then(cb.bind(null, null)).catch(cb);
-    return;
-  }
-
-  return promise;
-};
-
-/**
- * Exchange the token of the logged in user with a token that is valid to call
- * the API (signed with the API secret).
- *
- * @method
- * @memberOf module:auth.TokensManager.prototype
- *
- * @example <caption>
- *   Given an existing token, this endpoint will generate a new token signed
- *   with the target client secret. This is used to flow the identity of the
- *   user from the application to an API or across different APIs that are
- *   protected with different secrets. Find more information in the
- *   <a href="https://auth0.com/docs/auth-api#!#post--delegation">API Docs</a>.
- * </caption>
- *
- * var data = {
- *   id_token: '{ID_TOKEN}',
- *   api_type: 'app',
- *   target: '{TARGET}',
- *   grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer'
- * };
- *
- * auth0.tokens.getDelegationToken(data, function (err, token) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(token);
- * });
- *
- * @param   {Object}    data                Token data object.
- * @param   {String}    data.id_token       User ID token.
- * @param   {String}    data.refresh_token  User refresh token.
- * @param   {String}    data.target         Target client ID.
- * @param   {String}    data.api_type       The API to be used (aws, auth0, etc).
- * @param   {String}    data.grant_type     Grant type (password, jwt, etc).
- * @param   {Function}  [cb]                Callback function.
- *
- * @return  {Promise|undefined}
  */
-TokensManager.prototype.getDelegationToken = function(data, cb) {
-  var body = extend({ client_id: this.clientId }, data);
-  var headers = this.headers;
-
-  if (!data) {
-    throw new ArgumentError('Missing token data object');
-  }
-
-  var hasIdToken = typeof data.id_token === 'string' && data.id_token.trim().length !== 0;
-
-  var hasRefreshToken =
-    typeof data.refresh_token === 'string' && data.refresh_token.trim().length !== 0;
-
-  if (!hasIdToken && !hasRefreshToken) {
-    throw new ArgumentError('one of id_token or refresh_token is required');
-  }
-
-  if (hasIdToken && hasRefreshToken) {
-    throw new ArgumentError('id_token and refresh_token fields cannot be specified simulatenously');
+class TokensManager {
+  /**
+   * @param  {object}   options                 Manager options.
+   * @param  {string}   options.baseUrl         The auth0 account URL.
+   * @param  {string}   [options.headers]       Default request headers.
+   * @param  {string}   [options.clientId]      Default client ID.
+   * @param  {string}   [options.clientSecret]  Default client Secret.
+   */
+  constructor(options) {
+    if (typeof options !== 'object') {
+      throw new ArgumentError('Missing tokens manager options');
+    }
+
+    if (typeof options.baseUrl !== 'string') {
+      throw new ArgumentError('baseUrl field is required');
+    }
+
+    this.baseUrl = options.baseUrl;
+    this.headers = options.headers || {};
+    this.clientId = options.clientId || '';
+    this.clientSecret = options.clientSecret || '';
   }
 
-  if (typeof data.target !== 'string' || data.target.trim().length === 0) {
-    throw new ArgumentError('target field is required');
+  /**
+   * Given an ID token get the user profile linked to it.
+   *
+   * @example <caption>
+   *   Validates a JSON Web Token (signature and expiration) and returns the user
+   *   information associated with the user id (sub property) of the token. Find
+   *   more information in the
+   *   <a href="https://auth0.com/docs/auth-api#!#post--tokeninfo">API Docs</a>.
+   * </caption>
+   *
+   * auth0.tokens.getInfo(token, function (err, tokenInfo) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(tokenInfo);
+   * });
+   * @param   {string}    idToken     User ID token.
+   * @param   {Function}  [cb]        Method callback.
+   * @returns  {Promise|undefined}
+   */
+  getInfo(idToken, cb) {
+    const headers = { ...this.headers };
+
+    if (idToken === null || idToken === undefined) {
+      throw new ArgumentError('An ID token is required');
+    }
+
+    if (typeof idToken !== 'string' || idToken.trim().length === 0) {
+      throw new ArgumentError('The ID token is not valid');
+    }
+
+    // Perform the request.
+    const promise = axios({
+      method: 'POST',
+      url: `${this.baseUrl}/tokeninfo`,
+      data: { id_token: idToken },
+      headers,
+    }).then(({ data }) => data);
+
+    // Use callback if given.
+    if (cb instanceof Function) {
+      promise.then(cb.bind(null, null)).catch(cb);
+      return;
+    }
+
+    return promise;
   }
 
-  if (typeof data.api_type !== 'string' || data.api_type.trim().length === 0) {
-    throw new ArgumentError('api_type field is required');
+  /**
+   * Exchange the token of the logged in user with a token that is valid to call
+   * the API (signed with the API secret).
+   *
+   * @example <caption>
+   *   Given an existing token, this endpoint will generate a new token signed
+   *   with the target client secret. This is used to flow the identity of the
+   *   user from the application to an API or across different APIs that are
+   *   protected with different secrets. Find more information in the
+   *   <a href="https://auth0.com/docs/auth-api#!#post--delegation">API Docs</a>.
+   * </caption>
+   *
+   * var data = {
+   *   id_token: '{ID_TOKEN}',
+   *   api_type: 'app',
+   *   target: '{TARGET}',
+   *   grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer'
+   * };
+   *
+   * auth0.tokens.getDelegationToken(data, function (err, token) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(token);
+   * });
+   * @param   {object}    data                Token data object.
+   * @param   {string}    data.id_token       User ID token.
+   * @param   {string}    data.refresh_token  User refresh token.
+   * @param   {string}    data.target         Target client ID.
+   * @param   {string}    data.api_type       The API to be used (aws, auth0, etc).
+   * @param   {string}    data.grant_type     Grant type (password, jwt, etc).
+   * @param   {Function}  [cb]                Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getDelegationToken(data, cb) {
+    const body = { client_id: this.clientId, ...data };
+    const { headers } = this;
+
+    if (!data) {
+      throw new ArgumentError('Missing token data object');
+    }
+
+    const hasIdToken = typeof data.id_token === 'string' && data.id_token.trim().length !== 0;
+
+    const hasRefreshToken =
+      typeof data.refresh_token === 'string' && data.refresh_token.trim().length !== 0;
+
+    if (!hasIdToken && !hasRefreshToken) {
+      throw new ArgumentError('one of id_token or refresh_token is required');
+    }
+
+    if (hasIdToken && hasRefreshToken) {
+      throw new ArgumentError(
+        'id_token and refresh_token fields cannot be specified simulatenously'
+      );
+    }
+
+    if (typeof data.target !== 'string' || data.target.trim().length === 0) {
+      throw new ArgumentError('target field is required');
+    }
+
+    if (typeof data.api_type !== 'string' || data.api_type.trim().length === 0) {
+      throw new ArgumentError('api_type field is required');
+    }
+
+    if (typeof data.grant_type !== 'string' || data.grant_type.trim().length === 0) {
+      throw new ArgumentError('grant_type field is required');
+    }
+
+    // Perform the request.
+    const promise = axios({
+      method: 'POST',
+      url: `${this.baseUrl}/delegation`,
+      data: body,
+      headers,
+    }).then(({ data }) => data);
+
+    // Use callback if given.
+    if (cb instanceof Function) {
+      promise.then(cb.bind(null, null)).catch(cb);
+      return;
+    }
+
+    return promise;
   }
 
-  if (typeof data.grant_type !== 'string' || data.grant_type.trim().length === 0) {
-    throw new ArgumentError('grant_type field is required');
+  /**
+   * Proactively revoke an issued refresh token.
+   *
+   * @example <caption>
+   *   Given an existing refresh token, this endpoint will revoke it in order
+   *   to prevent unauthorized silently user authentication tokens refresh.
+   *   Find more information in the <a href="https://auth0.com/docs/api/authentication#revoke-refresh-token">API Docs</a>.
+   * </caption>
+   *
+   *  var data = {
+   *   token: '{REFRESH_TOKEN}'
+   * };
+   *
+   * auth0.tokens.revokeRefreshToken(data, function (err, _) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Do stuff.
+   * });
+   * @param   {object}    data                  Token data object.
+   * @param   {string}    data.token            User refresh token.
+   * @param   {string}    [data.client_id]      Target client ID.
+   * @param   {string}    [data.client_secret]  Target client secret.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  revokeRefreshToken(data, cb) {
+    if (!data) {
+      throw new ArgumentError('Missing token data object');
+    }
+
+    const hasToken = typeof data.token === 'string' && data.token.trim().length !== 0;
+
+    if (!hasToken) {
+      throw new ArgumentError('token property is required');
+    }
+
+    const hasClientId =
+      (data.client_id &&
+        typeof data.client_id === 'string' &&
+        data.client_id.trim().length !== 0) ||
+      this.clientId !== '';
+
+    if (!hasClientId) {
+      throw new ArgumentError(
+        'Neither token data client_id property or constructor clientId property has been set'
+      );
+    }
+
+    const body = {
+      client_id: this.clientId,
+      client_secret: this.clientSecret,
+      ...data,
+    };
+
+    const { headers } = this;
+
+    // Perform the request.
+    const promise = axios({
+      method: 'POST',
+      url: `${this.baseUrl}/oauth/revoke`,
+      data: body,
+      headers,
+    }).then(({ data }) => data);
+
+    // Use callback if given.
+    if (cb instanceof Function) {
+      promise.then(cb.bind(null, null)).catch(cb);
+      return;
+    }
+
+    return promise;
   }
-
-  // Perform the request.
-  var promise = getRequestPromise({
-    method: 'POST',
-    url: this.baseUrl + '/delegation',
-    data: body,
-    headers: headers
-  });
-
-  // Use callback if given.
-  if (cb instanceof Function) {
-    promise.then(cb.bind(null, null)).catch(cb);
-    return;
-  }
-
-  return promise;
-};
+}
 
 module.exports = TokensManager;
 
@@ -226,7 +294,7 @@

auth/TokensManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/auth_UsersManager.js.html b/docs/auth_UsersManager.js.html index 49fa17592..1aa27cc0d 100644 --- a/docs/auth_UsersManager.js.html +++ b/docs/auth_UsersManager.js.html @@ -24,7 +24,8 @@
@@ -39,177 +40,165 @@

auth/UsersManager.js

-
var extend = require('util')._extend;
-var getRequestPromise = require('../utils').getRequestPromise;
+            
const axios = require('axios');
 
-var ArgumentError = require('rest-facade').ArgumentError;
+const { ArgumentError } = require('rest-facade');
 
 /**
- * @class
  * Provides methods for getting user information and impersonating users.
- * @constructor
- * @memberOf module:auth
- *
- * @param  {Object}   options               Manager options.
- * @param  {String}   options.baseUrl       The auth0 account URL.
- * @param  {String}   [options.headers]     Default request headers.
- * @param  {String}   [options.clientId]    Default client ID.
  */
-var UsersManager = function(options) {
-  if (typeof options !== 'object') {
-    throw new ArgumentError('Missing users manager options');
+class UsersManager {
+  /**
+   * @param  {object}   options               Manager options.
+   * @param  {string}   options.baseUrl       The auth0 account URL.
+   * @param  {string}   [options.headers]     Default request headers.
+   * @param  {string}   [options.clientId]    Default client ID.
+   */
+  constructor(options) {
+    if (typeof options !== 'object') {
+      throw new ArgumentError('Missing users manager options');
+    }
+
+    if (typeof options.baseUrl !== 'string') {
+      throw new ArgumentError('baseUrl field is required');
+    }
+
+    this.baseUrl = options.baseUrl;
+    this.headers = options.headers;
+    this.clientId = options.clientId;
   }
 
-  if (typeof options.baseUrl !== 'string') {
-    throw new ArgumentError('baseUrl field is required');
+  /**
+   * Given an access token get the user profile linked to it.
+   *
+   * @example <caption>
+   *   Get the user information based on the Auth0 access token (obtained during
+   *   login). Find more information in the
+   *   <a href="https://auth0.com/docs/auth-api#!#get--userinfo">API Docs</a>.
+   * </caption>
+   *
+   * auth0.users.getInfo(accessToken, function (err, userInfo) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(userInfo);
+   * });
+   * @param   {string}    accessToken   User access token.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getInfo(accessToken, cb) {
+    const url = `${this.baseUrl}/userinfo`;
+    const headers = { ...this.headers };
+
+    if (accessToken === null || accessToken === undefined) {
+      throw new ArgumentError('An access token is required');
+    }
+
+    if (typeof accessToken !== 'string' || accessToken.trim().length === 0) {
+      throw new ArgumentError('Invalid access token');
+    }
+
+    // Send the user access token in the Authorization header.
+    headers['Authorization'] = `Bearer ${accessToken}`;
+
+    // Perform the request.
+    const promise = axios({
+      method: 'GET',
+      url,
+      headers,
+    }).then(({ data }) => data);
+
+    // Use callback if given.
+    if (cb instanceof Function) {
+      promise.then(cb.bind(null, null)).catch(cb);
+      return;
+    }
+
+    return promise;
   }
 
-  this.baseUrl = options.baseUrl;
-  this.headers = options.headers;
-  this.clientId = options.clientId;
-};
-
-/**
- * Given an access token get the user profile linked to it.
- *
- * @method    getInfo
- * @memberOf  module:auth.UsersManager.prototype
- *
- * @example <caption>
- *   Get the user information based on the Auth0 access token (obtained during
- *   login). Find more information in the
- *   <a href="https://auth0.com/docs/auth-api#!#get--userinfo">API Docs</a>.
- * </caption>
- *
- * auth0.users.getInfo(accessToken, function (err, userInfo) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(userInfo);
- * });
- *
- * @param   {String}    accessToken   User access token.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.getInfo = function(accessToken, cb) {
-  var url = this.baseUrl + '/userinfo';
-  var headers = extend({}, this.headers);
-
-  if (accessToken === null || accessToken === undefined) {
-    throw new ArgumentError('An access token is required');
-  }
-
-  if (typeof accessToken !== 'string' || accessToken.trim().length === 0) {
-    throw new ArgumentError('Invalid access token');
-  }
-
-  // Send the user access token in the Authorization header.
-  headers['Authorization'] = 'Bearer ' + accessToken;
-
-  // Perform the request.
-  var promise = getRequestPromise({
-    method: 'GET',
-    url: url,
-    headers: headers,
-    data: {}
-  });
-
-  // Use callback if given.
-  if (cb instanceof Function) {
-    promise.then(cb.bind(null, null)).catch(cb);
-    return;
-  }
-
-  return promise;
-};
-
-/**
- * Impersonate the user with the given user ID.
- *
- * @method    impersonate
- * @memberOf  module:auth.UsersManager.prototype
- *
- * @example <caption>
- *   Gets a link that can be used once to log in as a specific user. Useful for
- *   troubleshooting. Find more information in the
- *   [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate).
- * </caption>
- *
- * var settings = {
- *   impersonator_id: '{IMPERSONATOR_ID}',
- *   protocol: 'oauth2',
- *   additionalParameters: {}  // Optional aditional params.
- * };
- *
- * auth0.users.impersonate(userId, settings, function (err, link) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(link);
- * });
- *
- * @param   {String}    userId                    User ID token.
- * @param   {Object}    settings                  Impersonation settings.
- * @param   {String}    settings.impersonator_id  Impersonator user ID.
- * @param   {String}    settings.protocol         The authentication protocol.
- * @param   {String}    settings.token            API v1 token obtained for impersonation
- * @param   {String}    [settings.clientId]       Client id used for impersonation. Uses the one supplied in the constructor by default.
- * @param   {Function}  [cb]]                     Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.impersonate = function(userId, settings, cb) {
-  var url = this.baseUrl + '/users/' + userId + '/impersonate';
-
-  if (userId === null || userId === undefined) {
-    throw new ArgumentError('You must specify a user ID');
+  /**
+   * Impersonate the user with the given user ID.
+   *
+   * @example <caption>
+   *   Gets a link that can be used once to log in as a specific user. Useful for
+   *   troubleshooting. Find more information in the
+   *   [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate).
+   * </caption>
+   *
+   * var settings = {
+   *   impersonator_id: '{IMPERSONATOR_ID}',
+   *   protocol: 'oauth2',
+   *   additionalParameters: {}  // Optional additional params.
+   * };
+   *
+   * auth0.users.impersonate(userId, settings, function (err, link) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(link);
+   * });
+   * @param   {string}    userId                    User ID token.
+   * @param   {object}    settings                  Impersonation settings.
+   * @param   {string}    settings.impersonator_id  Impersonator user ID.
+   * @param   {string}    settings.protocol         The authentication protocol.
+   * @param   {string}    settings.token            API v1 token obtained for impersonation
+   * @param   {string}    [settings.clientId]       Client id used for impersonation. Uses the one supplied in the constructor by default.
+   * @param   {Function}  [cb]                      Callback function.
+   * @returns  {Promise|undefined}
+   */
+  impersonate(userId, settings, cb) {
+    const url = `${this.baseUrl}/users/${userId}/impersonate`;
+
+    if (userId === null || userId === undefined) {
+      throw new ArgumentError('You must specify a user ID');
+    }
+
+    if (typeof userId !== 'string' || userId.trim().length === 0) {
+      throw new ArgumentError('The user ID is not valid');
+    }
+
+    if (typeof settings !== 'object') {
+      throw new ArgumentError('Missing impersonation settings object');
+    }
+
+    if (
+      typeof settings.impersonator_id !== 'string' ||
+      settings.impersonator_id.trim().length === 0
+    ) {
+      throw new ArgumentError('impersonator_id field is required');
+    }
+
+    if (typeof settings.protocol !== 'string' || settings.protocol.trim().length === 0) {
+      throw new ArgumentError('protocol field is required');
+    }
+
+    if (typeof settings.token !== 'string' || settings.token.trim().length === 0) {
+      throw new ArgumentError('token field is required');
+    }
+
+    const data = { client_id: settings.clientId || this.clientId, ...settings };
+    const headers = { Authorization: `Bearer ${settings.token}`, ...this.headers };
+    // Perform the request.
+    const promise = axios({
+      method: 'POST',
+      headers,
+      data,
+      url,
+    }).then(({ data }) => data);
+
+    // Use callback if given.
+    if (cb instanceof Function) {
+      promise.then(cb.bind(null, null)).catch(cb);
+      return;
+    }
+
+    return promise;
   }
-
-  if (typeof userId !== 'string' || userId.trim().length === 0) {
-    throw new ArgumentError('The user ID is not valid');
-  }
-
-  if (typeof settings !== 'object') {
-    throw new ArgumentError('Missing impersonation settings object');
-  }
-
-  if (
-    typeof settings.impersonator_id !== 'string' ||
-    settings.impersonator_id.trim().length === 0
-  ) {
-    throw new ArgumentError('impersonator_id field is required');
-  }
-
-  if (typeof settings.protocol !== 'string' || settings.protocol.trim().length === 0) {
-    throw new ArgumentError('protocol field is required');
-  }
-
-  if (typeof settings.token !== 'string' || settings.token.trim().length === 0) {
-    throw new ArgumentError('token field is required');
-  }
-
-  var data = extend({ client_id: settings.clientId || this.clientId }, settings);
-  var headers = extend({ Authorization: `Bearer ${settings.token}` }, this.headers);
-  // Perform the request.
-  var promise = getRequestPromise({
-    method: 'POST',
-    headers: headers,
-    data: data,
-    url: url
-  });
-
-  // Use callback if given.
-  if (cb instanceof Function) {
-    promise.then(cb.bind(null, null)).catch(cb);
-    return;
-  }
-
-  return promise;
-};
+}
 
 module.exports = UsersManager;
 
@@ -224,7 +213,7 @@

auth/UsersManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/auth_idToken.js.html b/docs/auth_idToken.js.html new file mode 100644 index 000000000..e5c33badb --- /dev/null +++ b/docs/auth_idToken.js.html @@ -0,0 +1,228 @@ + + + + + + auth/idToken.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

auth/idToken.js

+ + + + + + + +
+
+
const urlDecodeB64 = function (data) {
+  return Buffer.from(data, 'base64').toString('utf8');
+};
+
+/**
+ * Decodes a string token into the 3 parts, throws if the format is invalid
+ *
+ * @param {string} token token
+ * @returns {object}
+ */
+const decode = function (token) {
+  const parts = token.split('.');
+
+  if (parts.length !== 3) {
+    throw new Error('ID token could not be decoded');
+  }
+
+  return {
+    _raw: token,
+    header: JSON.parse(urlDecodeB64(parts[0])),
+    payload: JSON.parse(urlDecodeB64(parts[1])),
+    signature: parts[2],
+  };
+};
+
+const DEFAULT_LEEWAY = 60; //default clock-skew, in seconds
+
+/**
+ * Validator for ID Tokens following OIDC spec.
+ *
+ * @param {string} token the string token to verify
+ * @param {object} options the options required to run this verification
+ * @returns {object} The decoded token payload, or throws an exception if validation failed
+ */
+const validate = function (token, options) {
+  if (!token) {
+    throw new Error('ID token is required but missing');
+  }
+
+  const decodedToken = decode(token);
+
+  // Check algorithm
+  const { header } = decodedToken;
+  if (header.alg !== 'RS256' && header.alg !== 'HS256') {
+    throw new Error(
+      `Signature algorithm of "${header.alg}" is not supported. Expected the ID token to be signed with "RS256" or "HS256".`
+    );
+  }
+
+  const { payload } = decodedToken;
+
+  // Issuer
+  if (!payload.iss || typeof payload.iss !== 'string') {
+    throw new Error('Issuer (iss) claim must be a string present in the ID token');
+  }
+  if (payload.iss !== options.issuer) {
+    throw new Error(
+      `Issuer (iss) claim mismatch in the ID token; expected "${options.issuer}", found "${payload.iss}"`
+    );
+  }
+
+  // Subject
+  if (!payload.sub || typeof payload.sub !== 'string') {
+    throw new Error('Subject (sub) claim must be a string present in the ID token');
+  }
+
+  // Audience
+  if (!payload.aud || !(typeof payload.aud === 'string' || Array.isArray(payload.aud))) {
+    throw new Error(
+      'Audience (aud) claim must be a string or array of strings present in the ID token'
+    );
+  }
+  if (Array.isArray(payload.aud) && !payload.aud.includes(options.audience)) {
+    throw new Error(
+      `Audience (aud) claim mismatch in the ID token; expected "${
+        options.audience
+      }" but was not one of "${payload.aud.join(', ')}"`
+    );
+  } else if (typeof payload.aud === 'string' && payload.aud !== options.audience) {
+    throw new Error(
+      `Audience (aud) claim mismatch in the ID token; expected "${options.audience}" but found "${payload.aud}"`
+    );
+  }
+
+  // Organization
+  if (options.organization) {
+    if (!payload.org_id || typeof payload.org_id !== 'string') {
+      throw new Error('Organization Id (org_id) claim must be a string present in the ID token');
+    }
+
+    if (payload.org_id !== options.organization) {
+      throw new Error(
+        `Organization Id (org_id) claim value mismatch in the ID token; expected "${options.organization}", found "${payload.org_id}"'`
+      );
+    }
+  }
+
+  // --Time validation (epoch)--
+  const now = Math.floor(Date.now() / 1000);
+  const leeway = options.leeway || DEFAULT_LEEWAY;
+
+  // Expires at
+  if (!payload.exp || typeof payload.exp !== 'number') {
+    throw new Error('Expiration Time (exp) claim must be a number present in the ID token');
+  }
+  const expTime = payload.exp + leeway;
+
+  if (now > expTime) {
+    throw new Error(
+      `Expiration Time (exp) claim error in the ID token; current time (${now}) is after expiration time (${expTime})`
+    );
+  }
+
+  // Issued at
+  if (!payload.iat || typeof payload.iat !== 'number') {
+    throw new Error('Issued At (iat) claim must be a number present in the ID token');
+  }
+
+  // Nonce
+  if (options.nonce) {
+    if (!payload.nonce || typeof payload.nonce !== 'string') {
+      throw new Error('Nonce (nonce) claim must be a string present in the ID token');
+    }
+    if (payload.nonce !== options.nonce) {
+      throw new Error(
+        `Nonce (nonce) claim mismatch in the ID token; expected "${options.nonce}", found "${payload.nonce}"`
+      );
+    }
+  }
+
+  // Authorized party
+  if (Array.isArray(payload.aud) && payload.aud.length > 1) {
+    if (!payload.azp || typeof payload.azp !== 'string') {
+      throw new Error(
+        'Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values'
+      );
+    }
+    if (payload.azp !== options.audience) {
+      throw new Error(
+        `Authorized Party (azp) claim mismatch in the ID token; expected "${options.audience}", found "${payload.azp}"`
+      );
+    }
+  }
+
+  // Authentication time
+  if (options.maxAge) {
+    if (!payload.auth_time || typeof payload.auth_time !== 'number') {
+      throw new Error(
+        'Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified'
+      );
+    }
+
+    const authValidUntil = payload.auth_time + options.maxAge + leeway;
+    if (now > authValidUntil) {
+      throw new Error(
+        `Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Currrent time (${now}) is after last auth at ${authValidUntil}`
+      );
+    }
+  }
+
+  return decodedToken;
+};
+
+module.exports = {
+  decode,
+  validate,
+};
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/auth_index.js.html b/docs/auth_index.js.html index 09545aa68..d7f838b9d 100644 --- a/docs/auth_index.js.html +++ b/docs/auth_index.js.html @@ -24,7 +24,8 @@
@@ -39,34 +40,26 @@

auth/index.js

-
/** @module auth **/
-
-var util = require('util');
-
-var pkg = require('../../package.json');
-var utils = require('../utils');
-var jsonToBase64 = utils.jsonToBase64;
-var ArgumentError = require('rest-facade').ArgumentError;
+            
const util = require('util');
+const utils = require('../utils');
+const { jsonToBase64 } = utils;
+const { ArgumentError } = require('rest-facade');
 
 // Authenticators.
-var OAuthAuthenticator = require('./OAuthAuthenticator');
-var DatabaseAuthenticator = require('./DatabaseAuthenticator');
-var PasswordlessAuthenticator = require('./PasswordlessAuthenticator');
+const OAuthAuthenticator = require('./OAuthAuthenticator');
+const DatabaseAuthenticator = require('./DatabaseAuthenticator');
+const PasswordlessAuthenticator = require('./PasswordlessAuthenticator');
 
 // Managers
-var UsersManager = require('./UsersManager');
-var TokensManager = require('./TokensManager');
+const UsersManager = require('./UsersManager');
+const TokensManager = require('./TokensManager');
 
-var BASE_URL_FORMAT = 'https://%s';
+const BASE_URL_FORMAT = 'https://%s';
 
 /**
- * @class
  * Authentication API SDK.
  *
- * This client must used to access Auth0's
- * <a href="https://auth0.com/docs/auth-api">Authentication API</a>.
- * @constructor
- * @memberOf module:auth
+ * This client must used to access Auth0's {@link https://auth0.com/docs/auth-api Authentication API}.
  *
  * @example <caption>
  *   The <b>AuthenticationClient</b> constructor takes an <i>optional</i> client
@@ -79,545 +72,539 @@ 

auth/index.js

* domain: '{YOUR_ACCOUNT}.auth0.com', * clientId: '{OPTIONAL_CLIENT_ID}' * }); - * - * @param {Object} options Options for the Authentication Client SDK. - * @param {String} options.domain AuthenticationClient server domain. - * @param {String} [options.clientId] Default client ID. - * @param {String} [options.clientSecret] Default client Secret. - * @param {String} [options.supportedAlgorithms] Algorithms that your application expects to receive */ -var AuthenticationClient = function(options) { - if (!options || typeof options !== 'object') { - throw new ArgumentError('Authentication Client SDK options must be an object'); +class AuthenticationClient { + /** + * @param {object} options Options for the Authentication Client SDK. + * @param {string} options.domain AuthenticationClient server domain. + * @param {string} [options.clientId] Default client ID. + * @param {string} [options.clientSecret] Default client Secret. + * @param {string} [options.supportedAlgorithms] Algorithms that your application expects to receive + * @param {boolean} [options.__bypassIdTokenValidation] Whether the id_token should be validated or not + * @param {object} [options.headers] Additional headers that will be added to the outgoing requests. + */ + constructor(options) { + if (!options || typeof options !== 'object') { + throw new ArgumentError('Authentication Client SDK options must be an object'); + } + + if (!options.domain || options.domain.length === 0) { + throw new ArgumentError('Must provide a domain'); + } + + const defaultHeaders = { + 'User-Agent': `node.js/${process.version.replace('v', '')}`, + 'Content-Type': 'application/json', + }; + + const managerOptions = { + clientId: options.clientId, + domain: options.domain, + clientSecret: options.clientSecret, + headers: Object.assign(defaultHeaders, options.headers || {}), + baseUrl: util.format(BASE_URL_FORMAT, options.domain), + supportedAlgorithms: options.supportedAlgorithms, + __bypassIdTokenValidation: options.__bypassIdTokenValidation, + }; + + if (options.telemetry !== false) { + const clientInfo = options.clientInfo || utils.generateClientInfo(); + if ('string' === typeof clientInfo.name && clientInfo.name) { + const telemetry = jsonToBase64(clientInfo); + managerOptions.headers['Auth0-Client'] = telemetry; + } + } + + /** + * OAuth authenticator. + * + * @type {OAuthAuthenticator} + */ + this.oauth = new OAuthAuthenticator(managerOptions); + + /** + * Database authenticator. + * + * @type {DatabaseAuthenticator} + */ + this.database = new DatabaseAuthenticator(managerOptions, this.oauth); + + /** + * Passwordless authenticator. + * + * @type {PasswordlessAuthenticator} + */ + this.passwordless = new PasswordlessAuthenticator(managerOptions, this.oauth); + + /** + * Users manager. + * + * @type {UsersManager} + */ + this.users = new UsersManager(managerOptions); + + /** + * Tokens manager. + * + * @type {TokensManager} + */ + this.tokens = new TokensManager(managerOptions); } - if (!options.domain || options.domain.length === 0) { - throw new ArgumentError('Must provide a domain'); - } + /** + * Start passwordless flow sending an email. + * + * @example <caption> + * Given the user `email` address, it will send an email with a link. You can + * then authenticate with this user opening the link and he will be + * automatically logged in to the application. Optionally, you can + * append/override parameters to the link (like `scope`, `redirect_uri`, + * `protocol`, `response_type`, etc.) using `authParams` object. + * + * Find more information in the + * <a href="https://auth0.com/docs/auth-api#!#post--with_email">API Docs</a> + * </caption> + * + * var data = { + * email: '{EMAIL}', + * authParams: {} // Optional auth params. + * }; + * + * auth0.requestMagicLink(data, function (err) { + * if (err) { + * // Handle error. + * } + * }; + * @param {object} data User data object. + * @param {string} data.email User email address. + * @param {object} [data.authParams] Authentication parameters. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + requestMagicLink(data, cb) { + data.send = 'link'; - var managerOptions = { - clientId: options.clientId, - domain: options.domain, - clientSecret: options.clientSecret, - headers: { - 'User-agent': 'node.js/' + process.version.replace('v', ''), - 'Content-Type': 'application/json' - }, - baseUrl: util.format(BASE_URL_FORMAT, options.domain), - supportedAlgorithms: options.supportedAlgorithms - }; - - if (options.telemetry !== false) { - var telemetry = jsonToBase64(options.clientInfo || this.getClientInfo()); - managerOptions.headers['Auth0-Client'] = telemetry; + return this.passwordless.sendEmail(data, cb); } /** - * OAuth authenticator. + * Start passwordless flow sending an email. + * + * @example <caption> + * Given the user `email` address, it will send an email with a verification + * code. You can then authenticate with this user using the `/oauth/ro` + * endpoint using the email as username and the code as password. + * + * Find more information in the + * <a href="https://auth0.com/docs/auth-api#!#post--with_email">API Docs</a> + * </caption> * - * @type {OAuthAuthenticator} + * var data = { + * email: '{EMAIL}', + * authParams: {} // Optional auth params. + * }; + * + * auth0.requestEmailCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * }; + * @param {object} data User data object. + * @param {string} data.email User email address. + * @param {object} [data.authParams] Authentication parameters. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.oauth = new OAuthAuthenticator(managerOptions); + requestEmailCode(data, cb) { + data.send = 'code'; + + return this.passwordless.sendEmail(data, cb); + } /** - * Database authenticator. + * Verify the given OTP which was sent on the given email. + * + * @example <caption> + * Given the user credentials (`email` and `otp`), authenticates + * with the provider using the `/oauth/token` endpoint. Upon successful + * authentication, returns a JSON object containing the `access_token` and + * `id_token`. + * </caption> * - * @type {DatabaseAuthenticator} + * var data = { + * email: '{EMAIL}', + * otp: '{VERIFICATION_CODE}' + * }; + * + * auth0.verifyEmailCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @example <caption> + * The user data object has the following structure. + * </caption> + * + * { + * id_token: String, + * access_token: String, + * token_type: String + * } + * @param {object} data Credentials object. + * @param {string} data.email Email. + * @param {string} data.otp Verification code. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.database = new DatabaseAuthenticator(managerOptions, this.oauth); + verifyEmailCode(data, cb) { + const translatedData = { + username: data.email, + realm: 'email', + otp: data.otp, + }; + + return this.passwordless.signIn(translatedData, cb); + } /** - * Passwordless authenticator. + * Start passwordless flow sending an SMS. * - * @type {PasswordlessAuthenticator} + * @example <caption> + * Given the user `phone_number`, it will send a SMS message with a + * verification code. You can then authenticate with this user using the + * `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as + * `password`: + * </caption> + * + * var data = { + * phone_number: '{PHONE}' + * }; + * + * auth0.requestSMSCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * }); + * @param {object} data User data object. + * @param {string} data.phone_number The user phone number. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.passwordless = new PasswordlessAuthenticator(managerOptions, this.oauth); + requestSMSCode(data, cb) { + const translatedData = { + phone_number: data.phoneNumber || data.phone_number, + }; + + return this.passwordless.sendSMS(translatedData, cb); + } /** - * Users manager. + * Sign in with the given user credentials. + * + * @example <caption> + * Given the user credentials (`phone_number` and `otp`), authenticates + * with the provider using the `/oauth/token` endpoint. Upon successful + * authentication, returns a JSON object containing the `access_token` and + * `id_token`. + * </caption> + * + * var data = { + * username: '{PHONE_NUMBER}' + * otp: '{VERIFICATION_CODE}' + * }; * - * @type {UsersManager} + * auth0.verifySMSCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @example <caption> + * Given the user credentials (`phone_number` and `password`), authenticates + * with the provider using the deprecated `/oauth/ro` endpoint. Upon successful + * authentication, returns a JSON object containing the `access_token` and + * `id_token`. + * </caption> + * + * var data = { + * username: '{PHONE_NUMBER}', + * password: '{VERIFICATION_CODE}' + * }; + * + * auth0.verifySMSCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @example <caption> + * The user data object has the following structure. + * </caption> + * + * { + * id_token: String, + * access_token: String, + * token_type: String + * } + * @param {object} data Credentials object. + * @param {string} data.username Phone number. + * @param {string} data.otp Verification code. Use this instead of `password` to use the `/oauth/token` endpoint. + * @param {string} data.password Verification code. Use this instead of `otp` to use the `/oauth/ro` endpoint. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.users = new UsersManager(managerOptions); + verifySMSCode(data, cb) { + const translatedData = { + username: data.phoneNumber || data.phone_number || data.username, + }; + + if (data.otp) { + translatedData.otp = data.otp; + } else { + translatedData.password = data.code || data.password; + } + + return this.passwordless.signIn(translatedData, cb); + } /** - * Tokens manager. + * Exchange the token of the logged in user with a token that is valid to call + * the API (signed with the API secret). + * + * @example <caption> + * Given an existing token, this endpoint will generate a new token signed + * with the target client secret. This is used to flow the identity of the + * user from the application to an API or across different APIs that are + * protected with different secrets. Find more information in the + * <a href="https://auth0.com/docs/auth-api#!#post--delegation">API Docs</a>. + * </caption> + * + * var data = { + * id_token: '{ID_TOKEN}', + * api_type: 'app', + * target: '{TARGET}', + * grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer' + * }; + * + * auth0.getDelegationToken(data, function (err, token) { + * if (err) { + * // Handle error. + * } * - * @type {TokensManager} + * console.log(token); + * }); + * @param {object} data Token data object. + * @param {string} data.id_token The user ID token. + * @param {string} data.api_type The API type (aws, firebase, etc). + * @param {string} data.target The target client ID. + * @param {string} data.grant_type The grant type. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.tokens = new TokensManager(managerOptions); -}; - -/** - * Return an object with information about the current client, - * - * @method getClientInfo - * @memberOf module:auth.AuthenticationClient.prototype - * - * @return {Object} Object containing client information. - */ -AuthenticationClient.prototype.getClientInfo = function() { - var clientInfo = { - name: 'node-auth0', - version: pkg.version, - dependencies: [], - environment: [ - { - name: 'node.js', - version: process.version.replace('v', '') - } - ] - }; - - // Add the dependencies to the client info object. - Object.keys(pkg.dependencies).forEach(function(name) { - clientInfo.dependencies.push({ - name: name, - version: pkg.dependencies[name] - }); - }); - - return clientInfo; -}; - -/** - * Start passwordless flow sending an email. - * - * @method requestMagicLink - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given the user `email` address, it will send an email with a link. You can - * then authenticate with this user opening the link and he will be - * automatically logged in to the application. Optionally, you can - * append/override parameters to the link (like `scope`, `redirect_uri`, - * `protocol`, `response_type`, etc.) using `authParams` object. - * - * Find more information in the - * <a href="https://auth0.com/docs/auth-api#!#post--with_email">API Docs</a> - * </caption> - * - * var data = { - * email: '{EMAIL}', - * authParams: {} // Optional auth params. - * }; - * - * auth0.requestMagicLink(data, function (err) { - * if (err) { - * // Handle error. - * } - * }; - * - * @param {Object} data User data object. - * @param {String} data.email User email address. - * @param {Object} [data.authParams] Authentication parameters. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.requestMagicLink = function(data, cb) { - data.send = 'link'; - - return this.passwordless.sendEmail(data, cb); -}; - -/** - * Start passwordless flow sending an email. - * - * @method requestEmailCode - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given the user `email` address, it will send an email with a verification - * code. You can then authenticate with this user using the `/oauth/ro` - * endpoint using the email as username and the code as password. - * - * Find more information in the - * <a href="https://auth0.com/docs/auth-api#!#post--with_email">API Docs</a> - * </caption> - * - * var data = { - * email: '{EMAIL}', - * authParams: {} // Optional auth params. - * }; - * - * auth0.requestEmailCode(data, function (err) { - * if (err) { - * // Handle error. - * } - * }; - * - * @param {Object} data User data object. - * @param {String} data.email User email address. - * @param {Object} [data.authParams] Authentication parameters. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.requestEmailCode = function(data, cb) { - data.send = 'code'; - - return this.passwordless.sendEmail(data, cb); -}; - -/** - * Start passwordless flow sending an SMS. - * - * @method requestSMSCode - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given the user `phone_number`, it will send a SMS message with a - * verification code. You can then authenticate with this user using the - * `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as - * `password`: - * </caption> - * - * var data = { - * phone_number: '{PHONE}' - * }; - * - * auth0.requestSMSCode(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * }); - * - * @param {Object} data User data object. - * @param {String} data.phone_number The user phone number. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.requestSMSCode = function(data, cb) { - var translatedData = { - phone_number: data.phoneNumber || data.phone_number - }; - - return this.passwordless.sendSMS(translatedData, cb); -}; - -/** - * Sign in with the given user credentials. - * - * @method verifySMSCode - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given the user credentials (`phone_number` and `code`), it will do the - * authentication on the provider and return a JSON with the `access_token` - * and `id_token`. - * </caption> - * - * var data = { - * username: '{PHONE_NUMBER}', - * password: '{VERIFICATION_CODE}' - * }; - * - * auth0.verifySMSCode(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @example <caption> - * The user data object has the following structure. - * </caption> - * - * { - * id_token: String, - * access_token: String, - * token_type: String - * } - * - * @param {Object} data Credentials object. - * @param {String} data.username Phone number. - * @param {String} data.password Verification code. - * @param {String} data.target Target client ID. - * @param {String} data.grant_type Grant type. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.verifySMSCode = function(data, cb) { - var translatedData = { - username: data.phoneNumber || data.phone_number || data.username, - password: data.code || data.password - }; - - return this.passwordless.signIn(translatedData, cb); -}; - -/** - * Exchange the token of the logged in user with a token that is valid to call - * the API (signed with the API secret). - * - * @method getDelegationToken - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given an existing token, this endpoint will generate a new token signed - * with the target client secret. This is used to flow the identity of the - * user from the application to an API or across different APIs that are - * protected with different secrets. Find more information in the - * <a href="https://auth0.com/docs/auth-api#!#post--delegation">API Docs</a>. - * </caption> - * - * var data = { - * id_token: '{ID_TOKEN}', - * api_type: 'app', - * target: '{TARGET}', - * grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer' - * }; - * - * auth0.getDelegationToken(data, function (err, token) { - * if (err) { - * // Handle error. - * } - * - * console.log(token); - * }); - * - * @param {Object} data Token data object. - * @param {String} data.id_token The user ID token. - * @param {String} data.api_type The API type (aws, firebase, etc). - * @param {String} data.target The target client ID. - * @param {String} data.grant_type The grant type. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.getDelegationToken = function(data, cb) { - var translatedData = { - id_token: data.id_token, - api_type: data.api || data.api_type, - scope: data.scope, - target: data.targetClientId || data.target, - grant_type: data.grant_type - }; - - return this.tokens.getDelegationToken(translatedData, cb); -}; - -/** - * Change password using a database or active directory service. - * - * @method changePassword - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given the user email, the connection specified and the new password to - * use, Auth0 will send a forgot password email. Once the user clicks on the - * confirm password change link, the new password specified in this POST will - * be set to this user. Find more information in the - * <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password"> - * API Docs</a>. - * </caption> - * - * var data = { - * email: '{EMAIL}', - * password: '{PASSWORD}', - * connection: 'Username-Password-Authentication' - * }; - * - * auth0.changePassword(data, function (err, message) { - * if (err) { - * // Handle error. - * } - * - * console.log(message); - * }); - * - * @param {Object} data User data object. - * @param {String} data.email User email. - * @param {String} data.password User password. - * @param {String} data.connection Identity provider for the user. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.changePassword = function(data, cb) { - var translatedData = { - connection: data.connection, - email: data.email || data.username, - password: data.password - }; - - return this.database.changePassword(data, cb); -}; + getDelegationToken(data, cb) { + const translatedData = { + id_token: data.id_token, + api_type: data.api || data.api_type, + scope: data.scope, + target: data.targetClientId || data.target, + grant_type: data.grant_type, + }; + + return this.tokens.getDelegationToken(translatedData, cb); + } -/** - * Request a change password email using a database or active directory service. - * - * @method requestChangePasswordEmail - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given the user email, the connection specified, Auth0 will send a change - * password email. once the user clicks on the confirm password change link, - * the new password specified in this POST will be set to this user. Find more - * information in the <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password> - * API Docs</a>. - * </caption> - * - * var data = { - * email: '{EMAIL}', - * connection: 'Username-Password-Authentication' - * }; - * - * auth0.requestChangePasswordEmail(data, function (err, message) { - * if (err) { - * // Handle error. - * } - * - * console.log(message); - * }); - * - * @param {Object} data User data object. - * @param {String} data.email User email. - * @param {String} data.connection Identity provider for the user. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.requestChangePasswordEmail = function(data, cb) { - var translatedData = { - connection: data.connection, - email: data.email || data.username - }; + /** + * Change password using a database or active directory service. + * + * @example <caption> + * Given the user email, the connection specified and the new password to + * use, Auth0 will send a forgot password email. Once the user clicks on the + * confirm password change link, the new password specified in this POST will + * be set to this user. Find more information in the + * <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password"> + * API Docs</a>. + * </caption> + * + * var data = { + * email: '{EMAIL}', + * password: '{PASSWORD}', + * connection: 'Username-Password-Authentication' + * }; + * + * auth0.changePassword(data, function (err, message) { + * if (err) { + * // Handle error. + * } + * + * console.log(message); + * }); + * @param {object} data User data object. + * @param {string} data.email User email. + * @param {string} data.password User password. + * @param {string} data.connection Identity provider for the user. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + changePassword(data, cb) { + return this.database.changePassword(data, cb); + } - return this.database.requestChangePasswordEmail(data, cb); -}; + /** + * Request a change password email using a database or active directory service. + * + * @example <caption> + * Given the user email, the connection specified, Auth0 will send a change + * password email. once the user clicks on the confirm password change link, + * the new password specified in this POST will be set to this user. Find more + * information in the <a href="https://auth0.com/docs/auth-api#!#post--dbconnections-change_password> + * API Docs</a>. + * </caption> + * + * var data = { + * email: '{EMAIL}', + * connection: 'Username-Password-Authentication', + * client_id: 'OS1VzKTVjizL0VCc9Hx2ae2aTPXWy6BD' + * }; + * + * auth0.requestChangePasswordEmail(data, function (err, message) { + * if (err) { + * // Handle error. + * } + * + * console.log(message); + * }); + * @param {object} data User data object. + * @param {string} data.email User email. + * @param {string} data.connection Identity provider for the user. + * @param {string} data.client_id Client ID of the Application requesting the password change, to be included in the email template. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + requestChangePasswordEmail(data, cb) { + return this.database.requestChangePasswordEmail(data, cb); + } -/** - * Given an access token get the user profile linked to it. - * - * @method getProfile - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Get the user information based on the Auth0 access token (obtained during - * login). Find more information in the - * <a href="https://auth0.com/docs/auth-api#!#get--userinfo">API Docs</a>. - * </caption> - * - * auth0.getProfile(data, function (err, userInfo) { - * if (err) { - * // Handle error. - * } - * - * console.log(userInfo); - * }); - * - * @param {String} accessToken The user access token. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(AuthenticationClient, 'getProfile', 'users.getInfo'); + /** + * Given an access token get the user profile linked to it. + * + * @example <caption> + * Get the user information based on the Auth0 access token (obtained during + * login). Find more information in the + * <a href="https://auth0.com/docs/auth-api#!#get--userinfo">API Docs</a>. + * </caption> + * + * auth0.getProfile(data, function (err, userInfo) { + * if (err) { + * // Handle error. + * } + * + * console.log(userInfo); + * }); + * @param {string} accessToken The user access token. + * @returns {Promise|undefined} + */ + getProfile(...args) { + return this.users.getInfo(...args); + } -/** - * Gets an access token using the client credentials grant flow. - * - * @method clientCredentialsGrant - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Gets an access token using the client credentials grant flow. Find more information in the - * <a href="https://auth0.com/docs/api-auth/config/asking-for-access-tokens">API Docs</a>. - * </caption> - * - * auth0.clientCredentialsGrant({ - * audience: 'https://tenant.auth0.com/api/v2/', - * scope: 'read:users update:users' - * }, function (err, response) { - * if (err) { - * // Handle error. - * } - * - * console.log(response); - * }); - * - * @param {Object} options - * @param {String} [options.scope] scopes to request to be added to the returned access token - * @param {String} [options.audience] audience or identifier of the API where the access token will be used, e.g. Auth0 Management API - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - AuthenticationClient, - 'clientCredentialsGrant', - 'oauth.clientCredentialsGrant' -); + /** + * Gets an access token using the client credentials grant flow. + * + * @example <caption> + * Gets an access token using the client credentials grant flow. Find more information in the + * <a href="https://auth0.com/docs/api-auth/config/asking-for-access-tokens">API Docs</a>. + * </caption> + * + * auth0.clientCredentialsGrant({ + * audience: 'https://tenant.auth0.com/api/v2/', + * scope: 'read:users update:users' + * }, function (err, response) { + * if (err) { + * // Handle error. + * } + * + * console.log(response); + * }); + * @param {object} options + * @param {string} [options.scope] scopes to request to be added to the returned access token + * @param {string} [options.audience] audience or identifier of the API where the access token will be used, e.g. Auth0 Management API + * @returns {Promise|undefined} + */ + clientCredentialsGrant(...args) { + return this.oauth.clientCredentialsGrant(...args); + } -/** - * Sign in using a username and password - * - * @method passwordGrant - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given the user's credentials perform the OAuth password grant - * or Password Realm grant if a realm is provided, - * it will return a JSON with the access_token and id_token. - * More information in the - * <a href="https://auth0.com/docs/api/authentication#resource-owner-password"> - * API Docs - * </a>. - * </caption> - * - * var data = { - * client_id: '{CLIENT_ID}', // Optional field. - * username: '{USERNAME}', - * password: '{PASSWORD}' - * realm: '{CONNECTION_NAME}', // Optional field. - * scope: 'openid' // Optional field. - * }; - * - * auth0.oauth.token(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} userData User credentials object. - * @param {String} userData.username Username. - * @param {String} userData.password User password. - * @param {String} [userData.realm] Name of the realm to use to authenticate or the connection name - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(AuthenticationClient, 'passwordGrant', 'oauth.passwordGrant'); + /** + * Sign in using a username and password + * + * @example <caption> + * Given the user's credentials perform the OAuth password grant + * or Password Realm grant if a realm is provided, + * it will return a JSON with the access_token and id_token. + * More information in the + * <a href="https://auth0.com/docs/api/authentication#resource-owner-password"> + * API Docs + * </a>. + * </caption> + * + * var data = { + * client_id: '{CLIENT_ID}', // Optional field. + * username: '{USERNAME}', + * password: '{PASSWORD}' + * realm: '{CONNECTION_NAME}', // Optional field. + * scope: 'openid' // Optional field. + * }; + * + * auth0.passwordGrant(data, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.username Username. + * @param {string} userData.password User password. + * @param {string} [userData.realm] Name of the realm to use to authenticate or the connection name + * @param {object} [options] Additional options. + * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header + * @returns {Promise|undefined} + */ + passwordGrant(...args) { + return this.oauth.passwordGrant(...args); + } -/** - * Sign in using a refresh token - * - * @method refreshToken - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example <caption> - * Given a refresh token from a previous authentication request, - * it will return a JSON with the access_token and id_token. - * More information in the - * <a href="https://auth0.com/docs/api/authentication#refresh-token"> - * API Docs - * </a>. - * </caption> - * - * var data = { - * client_id: '{CLIENT_ID}', // Optional field. - * refresh_token: '{REFRESH_TOKEN}', - * }; - * - * auth0.refreshToken(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} userData User credentials object. - * @param {String} userData.refresh_token Refresh token. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(AuthenticationClient, 'refreshToken', 'oauth.refreshToken'); + /** + * Sign in using a refresh token + * + * @example <caption> + * Given a refresh token from a previous authentication request, + * it will return a JSON with the access_token and id_token. + * More information in the + * <a href="https://auth0.com/docs/api/authentication#refresh-token"> + * API Docs + * </a>. + * </caption> + * + * var data = { + * client_id: '{CLIENT_ID}', // Optional field. + * refresh_token: '{REFRESH_TOKEN}', + * }; + * + * auth0.refreshToken(data, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.refresh_token Refresh token. + * @returns {Promise|undefined} + */ + refreshToken(...args) { + return this.oauth.refreshToken(...args); + } +} module.exports = AuthenticationClient;
@@ -632,7 +619,7 @@

auth/index.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/errors.js.html b/docs/errors.js.html new file mode 100644 index 000000000..8b0c49bbf --- /dev/null +++ b/docs/errors.js.html @@ -0,0 +1,121 @@ + + + + + + errors.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

errors.js

+ + + + + + + +
+
+
const util = require('util');
+
+const errors = (module.exports = {});
+
+const sanitizeErrors = function (collection) {
+  if (!collection) {
+    return;
+  }
+
+  Object.keys(collection).forEach((key) => {
+    if (key.toLowerCase().match('password|secret|authorization')) {
+      collection[key] = '[REDACTED]';
+    }
+  });
+};
+
+/**
+ * Given a response request error, sanitize sensitive data.
+ *
+ * @param {Error} error Error object
+ * @returns {Error}
+ */
+errors.sanitizeErrorRequestData = function (error) {
+  if (
+    !error.response ||
+    !error.response.request ||
+    (!error.response.request._data && !error.response.request._header)
+  ) {
+    return error;
+  }
+
+  sanitizeErrors(error.response.request._header);
+  sanitizeErrors(error.response.request._data);
+
+  return error;
+};
+
+/**
+ * Given an Api Error, modify the original error and sanitize
+ * sensitive information using sanitizeErrorRequestData
+ *
+ * @param {string} name New error name
+ * @param {string} message New error message
+ * @param {number} status New error status
+ * @param {any} requestInfo Request info to be attached on the error
+ * @param {any} originalError Original error to be attached on the error
+ */
+const SanitizedError = function (name, message, status, requestInfo, originalError) {
+  this.name = name || this.constructor.name || this.constructor.prototype.name || '';
+  this.message = message || '';
+  this.statusCode = status || (originalError && originalError.code);
+  this.requestInfo = Object.assign({}, requestInfo);
+  this.originalError = errors.sanitizeErrorRequestData(originalError);
+
+  Error.captureStackTrace(this, this.constructor);
+};
+
+util.inherits(SanitizedError, Error);
+
+errors.SanitizedError = SanitizedError;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/external-RestClient.html b/docs/external-RestClient.html index 65462a15f..dcdc7de0d 100644 --- a/docs/external-RestClient.html +++ b/docs/external-RestClient.html @@ -24,7 +24,8 @@
@@ -87,1007 +88,7 @@

Source:
- - - - - -
See:
-
- -
- - - - - - - - -

- - - - - - - - - - - - - - - - - - -
- -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- - - -
- - - - - - - -
- -
- -

- RestClient -

- - -
- -
-
- - -

Simple facade for consuming a REST API endpoint.

- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
@@ -1139,7 +140,7 @@


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/fonts/OpenSans-Semibold-webfont.eot b/docs/fonts/OpenSans-Semibold-webfont.eot old mode 100644 new mode 100755 diff --git a/docs/fonts/OpenSans-Semibold-webfont.svg b/docs/fonts/OpenSans-Semibold-webfont.svg old mode 100644 new mode 100755 diff --git a/docs/fonts/OpenSans-Semibold-webfont.ttf b/docs/fonts/OpenSans-Semibold-webfont.ttf old mode 100644 new mode 100755 diff --git a/docs/fonts/OpenSans-Semibold-webfont.woff b/docs/fonts/OpenSans-Semibold-webfont.woff old mode 100644 new mode 100755 diff --git a/docs/fonts/OpenSans-SemiboldItalic-webfont.eot b/docs/fonts/OpenSans-SemiboldItalic-webfont.eot old mode 100644 new mode 100755 diff --git a/docs/fonts/OpenSans-SemiboldItalic-webfont.svg b/docs/fonts/OpenSans-SemiboldItalic-webfont.svg old mode 100644 new mode 100755 diff --git a/docs/fonts/OpenSans-SemiboldItalic-webfont.ttf b/docs/fonts/OpenSans-SemiboldItalic-webfont.ttf old mode 100644 new mode 100755 diff --git a/docs/fonts/OpenSans-SemiboldItalic-webfont.woff b/docs/fonts/OpenSans-SemiboldItalic-webfont.woff old mode 100644 new mode 100755 diff --git a/docs/global.html b/docs/global.html new file mode 100644 index 000000000..da111e8e3 --- /dev/null +++ b/docs/global.html @@ -0,0 +1,985 @@ + + + + + + Global - Documentation + + + + + + + + + + + + + + + + + +
+ +

Global

+ + + + + + + +
+ +
+ +

+ +

+ + +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

decode(token) → {object}

+ + + + + +
+

Decodes a string token into the 3 parts, throws if the format is invalid

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
token + + +string + + + + +

token

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +object + + +
+
+ + + +
+ + + +
+ + +
+ + + +

generateClientInfo() → {object}

+ + + + + +
+

Return an object with information about the current client.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +object + + +
+
+ + +
+

Object containing client information.

+
+ + +
+ + + +
+ + +
+ + + +

jsonToBase64(json) → {string}

+ + + + + +
+

Given a JSON string, convert it to its base64 representation.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
json + + +object + + + + +

Json data

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +string + + +
+
+ + + +
+ + + +
+ + +
+ + + +

SanitizedError(name, message, status, requestInfo, originalError)

+ + + + + +
+

Given an Api Error, modify the original error and sanitize +sensitive information using sanitizeErrorRequestData

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + +

New error name

+ +
message + + +string + + + + +

New error message

+ +
status + + +number + + + + +

New error status

+ +
requestInfo + + +any + + + + +

Request info to be attached on the error

+ +
originalError + + +any + + + + +

Original error to be attached on the error

+ +
+ + + + + + + + + + + + + + + + +
+ + +
+ + + +

validate(token, options) → {object}

+ + + + + +
+

Validator for ID Tokens following OIDC spec.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
token + + +string + + + + +

the string token to verify

+ +
options + + +object + + + + +

the options required to run this verification

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +object + + +
+
+ + +
+

The decoded token payload, or throws an exception if validation failed

+
+ + +
+ + + +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 284900d46..273c96377 100644 --- a/docs/index.html +++ b/docs/index.html @@ -24,7 +24,8 @@
@@ -48,97 +49,83 @@
-

node-auth0

Build Status -NPM version -Coverage -License -Downloads

-

Node.js client library for the Auth0 platform.

-

Installation

  npm install auth0

Documentation

You can find this library documentation in this page.

-

For more information about auth0 check our documentation page.

-

Authentication API Client

This client must be used to access Auth0's Authentication API.

+

Node.js client library for Auth0

+

Release +Codecov +Downloads +License +CircleCI

+

📚 Documentation - 🚀 Getting Started - 💻 API Reference - 💬 Feedback

+

Documentation

+
    +
  • FAQs - frequently asked questions about node-auth0.
  • +
  • Docs Site - explore our docs site and learn more about Auth0
  • +
+

Getting Started

+

Requirements

+

This library supports the following tooling versions:

+
    +
  • Node.js: >=8.3.0
  • +
+

Installation

+

Using npm in your project directory run the following command:

+
npm install auth0
+
+

Configure the SDK

+

Authentication API Client

+

This client must be used to access Auth0's Authentication API.

The AuthenticationClient constructor takes an optional client ID, if specified it will be used as default value for all endpoints that accept a client ID.

var AuthenticationClient = require('auth0').AuthenticationClient;
 
 var auth0 = new AuthenticationClient({
   domain: '{YOUR_ACCOUNT}.auth0.com',
-  clientId: '{OPTIONAL_CLIENT_ID}'
-});

Management API Client

The Auth0 Management API is meant to be used by back-end servers or trusted parties performing administrative tasks. Generally speaking, anything that can be done through the Auth0 dashboard (and more) can also be done through this API.

+ clientId: '{OPTIONAL_CLIENT_ID}', +}); +

+

Management API Client

+
+

Note: When using the ManagementClient in a browser you should set telemetry: false.

+
+

The Auth0 Management API is meant to be used by back-end servers or trusted parties performing administrative tasks. Generally speaking, anything that can be done through the Auth0 dashboard (and more) can also be done through this API.

Initialize your client class with an API v2 token and a domain.

var ManagementClient = require('auth0').ManagementClient;
 
 var management = new ManagementClient({
   token: '{YOUR_API_V2_TOKEN}',
-  domain: '{YOUR_ACCOUNT}.auth0.com'
-});
-

Note: When using at browser you should use telemetry: false.

-
-

To obtain automatically a Management API token via the ManagementClient, you can specify the parameters clientId, clientSecret (use a Non Interactive Client) and optionally scope. -Behind the scenes the Client Credentials Grant is used to obtain the access_token and is by default cached for the duration of the returned expires_in value.

-
var ManagementClient = require('auth0').ManagementClient;
-var auth0 = new ManagementClient({
-  domain: '{YOUR_ACCOUNT}.auth0.com',
-  clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',
-  clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}',
-  scope: 'read:users update:users'
-});
-

Make sure your ClientId is allowed to request tokens from Management API in Auth0 Dashboard

-
-

To obtain a Management API token from your node backend, you can use Client Credentials Grant using your registered Auth0 Non Interactive Clients

-
var AuthenticationClient = require('auth0').AuthenticationClient;
-
-var auth0 = new AuthenticationClient({
   domain: '{YOUR_ACCOUNT}.auth0.com',
-  clientId: '{CLIENT_ID}',
-  clientSecret: '{CLIENT_SECRET}'
 });
-
-auth0.clientCredentialsGrant(
-  {
-    audience: 'https://{YOUR_ACCOUNT}.auth0.com/api/v2/',
-    scope: '{MANAGEMENT_API_SCOPES}'
-  },
-  function(err, response) {
-    if (err) {
-      // Handle error.
-    }
-    console.log(response.access_token);
-  }
-);

Also you can request a token when the user authenticates using any of our client side SDKs, e.g. auth0.js.

-

Promises and callbacks

Be aware that all methods can be used with promises or callbacks. However, when a callback is provided no promise will be returned.

-
// Using callbacks.
-management.getUsers(function(err, users) {
-  if (err) {
-    // handle error.
-  }
-  console.log(users);
-});
-
-// Using promises.
-management
-  .getUsers()
-  .then(function(users) {
-    console.log(users);
-  })
-  .catch(function(err) {
-    // Handle error.
-  });

What is Auth0?

Auth0 helps you to:

+
+

For other examples see the EXAMPLES.md document.

+

API Reference

+ +

Feedback

+

Contributing

+

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

-

Create a free Auth0 Account

    -
  1. Go to Auth0 and click "Try Auth0 for Free".
  2. -
  3. Use Google, GitHub or Microsoft Account to login.
  4. -
-

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

-

Author

Auth0

-

License

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

-
+

Raise an issue

+

To provide feedback or report a bug, please raise an issue on our issue tracker.

+

Vulnerability Reporting

+

Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

+

What is Auth0?

+

+ + + + Auth0 Logo + +

+

+ Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0? +

+

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

@@ -151,7 +138,7 @@

License

This project is licensed under the MIT license. See the

- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/index.js.html b/docs/index.js.html index 1c8d473a0..0179a0dd2 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -24,7 +24,8 @@
@@ -41,13 +42,14 @@

index.js

/**
  * Simple facade for consuming a REST API endpoint.
+ *
  * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
+ * {@link https://github.com/ngonzalvez/rest-facade}
  */
 
 module.exports = {
   ManagementClient: require('./management'),
-  AuthenticationClient: require('./auth')
+  AuthenticationClient: require('./auth'),
 };
 
@@ -61,7 +63,7 @@

index.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_ActionsManager.js.html b/docs/management_ActionsManager.js.html new file mode 100644 index 000000000..e6dc13fdf --- /dev/null +++ b/docs/management_ActionsManager.js.html @@ -0,0 +1,587 @@ + + + + + + management/ActionsManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/ActionsManager.js

+ + + + + + + +
+
+
const BaseManager = require('./BaseManager');
+
+/**
+ * {@link https://auth0.com/docs/api/v2#!/Actions/get_actions Actions} provide a way to extend
+ * Auth0 flows with custom logic.
+ * See the {@link https://auth0.com/docs/actions Actions documentation} for more information.
+ */
+class ActionsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * [Auth0 Actions endpoint]{@link https://auth0.com/docs/api/v2#!/actions}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/actions/actions/:id');
+
+    this.actionsDeploy = this._getRestClient('/actions/actions/:id/deploy');
+
+    this.actionsTest = this._getRestClient('/actions/actions/:id/test');
+
+    this.triggers = this._getRestClient('/actions/triggers/:trigger_id');
+
+    this.triggerBindings = this._getRestClient('/actions/triggers/:trigger_id/bindings');
+
+    this.executions = this._getRestClient('/actions/executions/:execution_id');
+
+    this.actionVersions = this._getRestClient('/actions/actions/:id/versions/:version_id');
+
+    this.actionVersionDeploy = this._getRestClient(
+      '/actions/actions/:id/versions/:version_id/deploy'
+    );
+  }
+
+  /**
+   * Get all Triggers.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   * management.actions.getAllTriggers(params, function (err, actions) {
+   *   console.log(actions.length);
+   * });
+   * @param   {object}    [params]               Actions parameters.
+   * @param   {number}    [params.per_page]      Number of results per page.
+   * @param   {number}    [params.page]          Page number, zero indexed.
+   * @param   {Function}  [cb]                   Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAllTriggers(params, cb) {
+    params = params || {};
+
+    if (cb && cb instanceof Function) {
+      return this.triggers.getAll(params, cb);
+    }
+
+    return this.triggers.getAll(params);
+  }
+
+  /**
+   * Update the actions bound to a trigger .
+   *
+   * @example
+   * var data = { bindings: [{ id_type: "action_id", id_value: ACTION_ID1},{id_type: "action_name", id_value: ACTION_NAME2}];
+   * var params = { trigger_id: TRIGGER_ID };
+   *
+   * // Using auth0 instance.
+   * management.actions.updateTriggerBindings(params, data, function (err, bindings) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(bindings.length);  // 2
+   * });
+   * @param   {object}    params                Actions Binding parameters.
+   * @param   {string}    params.trigger_id     Actions Trigger ID.
+   * @param   {object}    data                  bindings array
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  updateTriggerBindings(params, data, cb) {
+    params = params || {};
+
+    if (cb && cb instanceof Function) {
+      return this.triggerBindings.patch(params, data, cb);
+    }
+
+    return this.triggerBindings.patch(params, data);
+  }
+
+  /**
+   * Get the actions bound to a trigger .
+   *
+   * @example
+   * var params = { trigger_id: TRIGGER_ID };
+   *
+   * // Using auth0 instance.
+   * management.actions.getTriggerBindings(params, function (err, bindings) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(bindings.length);  // 2
+   * });
+   * @param   {object}    params                Actions Binding parameters.
+   * @param   {string}    params.trigger_id     Actions Trigger ID.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getTriggerBindings(params, cb) {
+    params = params || {};
+
+    if (cb && cb instanceof Function) {
+      return this.triggerBindings.getAll(params, cb);
+    }
+
+    return this.triggerBindings.getAll(params);
+  }
+
+  /**
+   * Create a new Action.
+   *
+   * @example
+   * management.actions.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Action created.
+   * });
+   * @param   {object}    data     Action data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.resource.create(...args);
+  }
+
+  /**
+   * Get all actions.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0,
+   *   triggerId:'TRIGGER_ID',
+   *   actionName: 'ACTION_NAME'
+   * };
+   *
+   * management.actions.getAll(params, function (err, actions) {
+   *   console.log(actions.length);
+   * });
+   * @param   {object}    [params]               Actions parameters.
+   * @param   {number}    [params.per_page]      Number of results per page.
+   * @param   {number}    [params.page]          Page number, zero indexed.
+   * @param   {string}    [params.triggerId]     The trigger ID of the actions to retrieve.
+   * @param   {string}    [params.actionName]    The name of the actions to retrieve.
+   * @param   {Function}  [cb]                   Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
+
+  /**
+   * Get an Auth0 action.
+   *
+   * @example
+   * management.actions.get({ id: ACTION_ID }, function (err, action) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(action);
+   * });
+   * @param   {object}    params               Action parameters.
+   * @param   {string}    params.id     Action ID.
+   * @param   {Function}  [cb]                 Callback function.
+   * @returns  {Promise|undefined}
+   */
+  get(params, cb) {
+    params = params || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.resource.get(params, cb);
+    }
+
+    return this.resource.get(params);
+  }
+
+  /**
+   * Update an existing action.
+   *
+   * @example
+   * var data = { name: 'new-name' };
+   * var params = { id: ACTION_ID };
+   *
+   * // Using auth0 instance.
+   * management.updateAction(params, data, function (err, action) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(action.name);  // 'new-name'
+   * });
+   *
+   * // Using the Actions manager directly.
+   * management.actions.update(params, data, function (err, action) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(action.name);  // 'new-name'
+   * });
+   * @param   {object}    params        Action parameters.
+   * @param   {string}    params.id     Action ID.
+   * @param   {object}    data          Updated action data.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  update(params, data, cb) {
+    params = params || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.resource.patch(params, data, cb);
+    }
+
+    return this.resource.patch(params, data);
+  }
+
+  /**
+   * Delete an existing action. Deleting an Action deletes all the action's versions
+   *
+   * @example
+   * management.actions.delete({ id: ACTION_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Action deleted.
+   * });
+   * @param   {object}    params        Action parameters.
+   * @param   {string}    params.id     Action ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  delete(params, cb) {
+    params = params || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.resource.delete(params, cb);
+    }
+
+    return this.resource.delete(params);
+  }
+
+  /**
+   * test an Action.
+   *
+   * @example
+   * var params = { id: ACTION_ID};
+   * management.actions.test(params, payload, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Action parameters.
+   * @param   {string}    params.id      Action ID.
+   * @param   {object}    payload               Payload represents the entire structure necessary to test a particular trigger
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  test(params, payload, cb) {
+    params = params || {};
+    payload = payload || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.actionsTest.create(params, payload, cb);
+    }
+
+    return this.actionsTest.create(params, payload);
+  }
+
+  /**
+   * deploy an Action.
+   * The action must be in a state of 'built' before it can be deployed.
+   *
+   * @example
+   * var params = { id: ACTION_ID};
+   * mangement.actions.deploy(params, function (err, actionVersion) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Action parameters.
+   * @param   {string}    params.id      Action ID.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  deploy(params, cb) {
+    params = params || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.actionsDeploy.create(params, {}, cb);
+    }
+
+    return this.actionsDeploy.create(params, {});
+  }
+
+  /**
+   * Get all action versions
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   * management.actions.getVersions({ id: ACTION_ID }, function (err, actionVersions) {
+   *   console.log(actionVersions.length);
+   * });
+   * @param   {object}    [params]               ActionVersions parameters.
+   * @param   {number}    [params.per_page]      Number of results per page.
+   * @param   {number}    [params.page]          Page number, zero indexed.
+   * @param   {string}    [params.id]     Action ID.
+   * @param   {Function}  [cb]                   Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getVersions(params, cb) {
+    params = params || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.actionVersions.getAll(params, cb);
+    }
+
+    return this.actionVersions.getAll(params);
+  }
+
+  /**
+   * Get an Action Version.
+   *
+   * @example
+   * var params = { id: ACTION_ID, version_id: VERSION_ID };
+   * management.actions.getVersion(params, function (err, actionVersion) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Action parameters.
+   * @param   {string}    params.id      Action ID.
+   * @param   {string}    params.version_id     ActionVersion ID.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getVersion(params, cb) {
+    params = params || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.actionVersions.get(params, cb);
+    }
+
+    return this.actionVersions.get(params);
+  }
+
+  /**
+   * Create an Action Version. In general, updating an action and then
+   * deploying it is the preferred way of creating an action version, but
+   * this operation is supported as a way of creating versions without
+   * updating the action's code (which can be useful in some CI/CD scenarios).
+   *
+   * @example
+   * var params = { id: ACTION_ID };
+   * management.actions.createActionVersion(params, data, function (err, actionVersion) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Action parameters.
+   * @param   {string}    params.id      Action ID.
+   * @param   {object}    data                  ActionVersion parameters.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  createVersion(params, data, cb) {
+    params = params || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.actionVersions.create(params, data, cb);
+    }
+
+    return this.actionVersions.create(params, data);
+  }
+
+  /**
+   * deploy an Action Version to roll back to a previous version.
+   *
+   * @example
+   * var params = { id: ACTION_ID, version_id: VERSION_ID };
+   * management.actions.deployVersion(params, function (err, actionVersion) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Action parameters.
+   * @param   {string}    params.id      Action ID.
+   * @param   {string}    params.version_id     Action ID.
+   * @param   {boolean}   params.update_draft   Update draft
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  deployVersion(params, cb) {
+    params = params || {};
+
+    if (params.action_id) {
+      params.id = params.action_id;
+      delete params.action_id;
+    }
+
+    const body = {};
+
+    if (params.update_draft) {
+      body.update_draft = params.update_draft;
+      delete params.update_draft;
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.actionVersionDeploy.create(params, body, cb);
+    }
+
+    return this.actionVersionDeploy.create(params, body);
+  }
+
+  /**
+   * Get an execution by ID.
+   *
+   * @example
+   * management.actions.getExecution({ execution_id: EXECUTION_ID }, function (err, action) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(ActionExecution);
+   * });
+   * @param   {object}    params                  Action Execution parameters.
+   * @param   {string}    params.id     Action Execution ID.
+   * @param   {Function}  [cb]                    Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getExecution(params, cb) {
+    params = params || {};
+
+    if (cb && cb instanceof Function) {
+      return this.executions.get(params, cb);
+    }
+
+    return this.executions.get(params);
+  }
+}
+
+module.exports = ActionsManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_AttackProtectionManager.js.html b/docs/management_AttackProtectionManager.js.html new file mode 100644 index 000000000..773bd04ed --- /dev/null +++ b/docs/management_AttackProtectionManager.js.html @@ -0,0 +1,219 @@ + + + + + + management/AttackProtectionManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/AttackProtectionManager.js

+ + + + + + + +
+
+
const BaseManager = require('./BaseManager');
+
+/**
+ * Simple facade for consuming a REST API endpoint.
+ *
+ * @external RestClient
+ * @see https://github.com/ngonzalvez/rest-facade
+ */
+
+class AttackProtectionManager extends BaseManager {
+  /**
+   * @class
+   * Abstracts interaction with the attack-protection endpoints.
+   * @class
+   * @param {object} options                 The client options.
+   * @param {string} options.baseUrl         The URL of the API.
+   * @param {object} [options.headers]       Headers to be included in all requests.
+   * @param {object} [options.retry]         Retry Policy Config
+   * @param {object} [options.tokenProvider] Management API Token Provider
+   */
+  constructor(options) {
+    super(options);
+
+    this.bruteForceProtection = this._getRestClient('/attack-protection/brute-force-protection');
+
+    this.suspiciousIpThrottling = this._getRestClient(
+      '/attack-protection/suspicious-ip-throttling'
+    );
+
+    this.breachedPasswordDetection = this._getRestClient(
+      '/attack-protection/breached-password-detection'
+    );
+  }
+
+  /**
+   * Get the Brute Force Protection configuration.
+   *
+   * @example
+   * management.attackProtection.getBruteForceConfig(params, function (err, bruteForceConfig) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Brute force config
+   *   console.log(bruteForceConfig);
+   * });
+   * @param   {object}    params            Brute force parameters (leave empty).
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  getBruteForceConfig(...args) {
+    return this.bruteForceProtection.get(...args);
+  }
+
+  /**
+   * Update the Brute Force Protection configuration.
+   *
+   * @example
+   * management.attackProtection.updateBruteForceConfig(params, data, function (err, bruteForceConfig) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Brute force config
+   *   console.log(bruteForceConfig);
+   * });
+   * @param   {object}    params            Brute force parameters (leave empty).
+   * @param   {object}    data              Updated brute force configuration.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  updateBruteForceConfig(...args) {
+    return this.bruteForceProtection.patch(...args);
+  }
+
+  /**
+   * Get the Suspicious IP Throttling configuration.
+   *
+   * @example
+   * management.attackProtection.getSuspiciousIpThrottlingConfig(params, function (err, suspiciousIpThrottlingConfig) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Access suspicious IP throttling configuration
+   *   console.log(suspiciousIpThrottlingConfig);
+   * });
+   * @param   {object}    params            Suspicious IP throttling parameters (leave empty).
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  getSuspiciousIpThrottlingConfig(...args) {
+    return this.suspiciousIpThrottling.get(...args);
+  }
+
+  /**
+   * Update the Suspicious IP Throttling configuration.
+   *
+   * @example
+   * management.attackProtection.updateSuspiciousIpThrottlingConfig(params, data, function (err, suspiciousIpThrottlingConfig) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Access suspicious IP throttling configuration
+   *   console.log(suspiciousIpThrottlingConfig);
+   * });
+   * @param   {object}    params            Suspicious IP throttling parameters (leave empty).
+   * @param   {object}    data              Updated suspicious IP throttling configuration.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  updateSuspiciousIpThrottlingConfig(...args) {
+    return this.suspiciousIpThrottling.patch(...args);
+  }
+
+  /**
+   * Get the Breached Password Detection configuration.
+   *
+   * @example
+   * management.attackProtection.getBreachedPasswordDetectionConfig(params, function (err, breachedPasswordDetectionConfig) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Access breached password detection configuration
+   *   console.log(breachedPasswordDetectionConfig);
+   * });
+   * @param   {object}    params            Breached password detection parameters (leave empty).
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  getBreachedPasswordDetectionConfig(...args) {
+    return this.breachedPasswordDetection.get(...args);
+  }
+
+  /**
+   * Update the breached password detection configuration.
+   *
+   * @example
+   * management.attackProtection.updateBreachedPasswordDetectionConfig(params, data, function (err, breachedPasswordDetectionConfig) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Access breached password detection configuration
+   *   console.log(breachedPasswordDetectionConfig);
+   * });
+   * @param   {object}    params            Breached password detection parameters (leave empty).
+   * @param   {object}    data              Updated breached password detection configuration.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  updateBreachedPasswordDetectionConfig(...args) {
+    return this.breachedPasswordDetection.patch(...args);
+  }
+}
+module.exports = AttackProtectionManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_BlacklistedTokensManager.js.html b/docs/management_BlacklistedTokensManager.js.html index 48fdcb021..6f8142581 100644 --- a/docs/management_BlacklistedTokensManager.js.html +++ b/docs/management_BlacklistedTokensManager.js.html @@ -24,7 +24,8 @@
@@ -39,106 +40,71 @@

management/BlacklistedTokensManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * @class BlacklistedTokensManager
  * The BlacklistedTokensManager class provides methods to retrieve the list of
  * blacklisted tokens and blacklist new ones..
- * @constructor
- * @memberOf  module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var BlacklistedTokensManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide client options');
-  }
-
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
-  }
-
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+class BlacklistedTokensManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * [Auth0 Blacklisted Tokens endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/blacklists/tokens');
   }
 
   /**
-   * Options object for the Rest Client instace.
+   * Blacklist a new token.
+   *
+   * @example
+   * var token = {
+   *  aud: 'aud',
+   *  jti: 'jti'
+   * };
+   *
+   * management.blacklistedTokens.add(token, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
    *
-   * @type {Object}
+   *   // Token blacklisted.
+   * });
+   * @param   {object}    token      Token data.
+   * @param   {string}    token.aud  Audience (your app client ID).
+   * @param   {string}    token.jti  The JWT ID claim.
+   * @param   {Function}  [cb]       Callback function.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  add(...args) {
+    return this.resource.create(...args);
+  }
 
   /**
-   * Provides an abstraction layer for consuming the
-   * [Auth0 Blacklisted Tokens endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
+   * Get all blacklisted tokens.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.blacklistedTokens.getAll(function (err, tokens) {
+   *   console.log(tokens.length);
+   * });
+   * @param   {Function}  [cb]    Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/blacklists/tokens',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
-
-/**
- * Blacklist a new token.
- *
- * @method    add
- * @memberOf  module:management.BlacklistedTokensManager.prototype
- *
- * @example
- * var token = {
- *  aud: 'aud',
- *  jti: 'jti'
- * };
- *
- * management.blacklistedTokens.add(token, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Token blacklisted.
- * });
- *
- * @param   {Object}    token      Token data.
- * @param   {String}    token.aud  Audience (your app client ID).
- * @param   {String}    token.jti  The JWT ID claim.
- * @param   {Function}  [cb]       Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(BlacklistedTokensManager, 'add', 'resource.create');
-
-/**
- * Get all blacklisted tokens.
- *
- * @method    getAll
- * @memberOf  module:management.BlacklistedTokensManager.prototype
- *
- * @example
- * management.blacklistedTokens.getAll(function (err, tokens) {
- *   console.log(tokens.length);
- * });
- *
- * @param   {Function}  [cb]    Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(BlacklistedTokensManager, 'getAll', 'resource.getAll');
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
+}
 
 module.exports = BlacklistedTokensManager;
 
@@ -153,7 +119,7 @@

management/BlacklistedTokensManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_BrandingManager.js.html b/docs/management_BrandingManager.js.html new file mode 100644 index 000000000..5023f83f8 --- /dev/null +++ b/docs/management_BrandingManager.js.html @@ -0,0 +1,311 @@ + + + + + + management/BrandingManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/BrandingManager.js

+ + + + + + + +
+
+
const BaseManager = require('./BaseManager');
+
+/**
+ * Manages settings related to branding.
+ */
+class BrandingManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/management/v2#!/Branding Branding endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/branding');
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/management/v2#!/Branding/get_universal_login Branding new universal login template endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.brandingTemplates = this._getRestClient('/branding/templates/universal-login');
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/management/v2#!/Branding/get_branding_theme Branding theme endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.brandingThemes = this._getRestClient('/branding/themes/:id');
+  }
+
+  /**
+   * Update the branding settings.
+   *
+   * @example
+   * management.branding.updateSettings(params, data, function (err, branding) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   * // Updated branding
+   *    console.log(branding);
+   * });
+   * @param   {object}    params            Branding parameters (leavy empty).
+   * @param   {object}    data              Updated branding data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  updateSettings(...args) {
+    return this.resource.patch(...args);
+  }
+
+  /**
+   * Get the branding settings..
+   *
+   * @example
+   * management.branding.getSettings(data, function (err, branding) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   * // Branding
+   *    console.log(branding);
+   * });
+   * @param   {object}    params            Branding parameters.
+   * @param   {object}    data              Branding data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  getSettings(...args) {
+    return this.resource.get(...args);
+  }
+
+  /**
+   * Get the new universal login template.
+   *
+   * @example
+   * management.branding.getUniversalLoginTemplate(data, function (err, template) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   * // Branding
+   *    console.log(template);
+   * });
+   * @param   {object}    params            Branding parameters (leave empty).
+   * @param   {object}    data              Branding data (leave empty).
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  getUniversalLoginTemplate(...args) {
+    return this.brandingTemplates.get(...args);
+  }
+
+  /**
+   * Set the new universal login template.
+   *
+   * @example
+   * management.branding.setUniversalLoginTemplate(params, data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params            Branding parameters (leavy empty).
+   * @param   {object}    data              Branding data (object with template field).
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  setUniversalLoginTemplate(...args) {
+    return this.brandingTemplates.update(...args);
+  }
+
+  /**
+   * Delete the new universal login template (revert to default).
+   *
+   * @example
+   * management.branding.deleteUniversalLoginTemplate(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params            Branding parameters (leavy empty).
+   * @param   {object}    data              Branding data (leave empty).
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  deleteUniversalLoginTemplate(...args) {
+    return this.brandingTemplates.delete(...args);
+  }
+
+  /**
+   * Get the new universal login theme by id.
+   *
+   * @example
+   * var params = { id: THEME_ID };
+   *
+   * management.branding.getTheme(params, function (err, theme) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *    // Theme
+   *    console.log(theme);
+   * });
+   * @param   {object}    params            Theme params
+   * @param   {object}    params.id         Theme identifier.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  getTheme(...args) {
+    return this.brandingThemes.get(...args);
+  }
+
+  /**
+   * Get the default new universal login theme.
+   *
+   * @example
+   * management.branding.getDefaultTheme(function (err, theme) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *    // Theme
+   *    console.log(theme);
+   * });
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  getDefaultTheme(...args) {
+    return this.brandingThemes.get(...[{ id: 'default' }].concat(args));
+  }
+
+  /**
+   * Create a new theme.
+   *
+   * @example
+   * management.branding.createTheme(data, function (err, theme) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Theme created.
+   *   console.log(theme);
+   * });
+   * @param   {object}    data     theme data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  createTheme(...args) {
+    return this.brandingThemes.create(...args);
+  }
+
+  /**
+   * Update a theme.
+   *
+   * @example
+   * var data = THEME_OBJ;
+   * var params = { id: THEME_ID };
+   *
+   * management.branding.updateTheme(params, data, function (err, theme) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Theme updated.
+   *   console.log(theme);
+   * });
+   * @param   {object}    params            Theme parameters.
+   * @param   {object}    params.id         Theme identifier.
+   * @param   {object}    data              Updated theme data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  updateTheme(...args) {
+    return this.brandingThemes.patch(...args);
+  }
+
+  /**
+   * Delete a theme.
+   *
+   * @example
+   * var params = { id: THEME_ID };
+   *
+   * management.branding.deleteTheme(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Theme deleted.
+   * });
+   * @param   {object}    params            Theme parameters.
+   * @param   {object}    params.id         Theme identifier.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  deleteTheme(...args) {
+    return this.brandingThemes.delete(...args);
+  }
+}
+
+module.exports = BrandingManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_ClientGrantsManager.js.html b/docs/management_ClientGrantsManager.js.html index 02d124357..eee517ef7 100644 --- a/docs/management_ClientGrantsManager.js.html +++ b/docs/management_ClientGrantsManager.js.html @@ -24,7 +24,8 @@
@@ -39,169 +40,128 @@

management/ClientGrantsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
+
 /**
- * @class ClientGrantsManager
  * Auth0 Client Grants Manager.
  *
  * See {@link https://auth0.com/docs/api/v2#!/Client_Grants Client Grants}
- *
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var ClientGrantsManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide client options');
+class ClientGrantsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Client_Grants Auth0 Client Grants endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/client-grants/:id');
   }
 
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
+  /**
+   * Create an Auth0 client grant.
+   *
+   * @example
+   * management.clientGrants.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Client grant created.
+   * });
+   * @param   {object}    data     The client data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.resource.create(...args);
   }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+  /**
+   * Get all Auth0 Client Grants.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   *
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   *
+   * management.clientGrants.getAll(params, function (err, grants) {
+   *   console.log(grants.length);
+   * });
+   * @param   {object}    [params]          Client Grants parameters.
+   * @param   {number}    [params.per_page] Number of results per page.
+   * @param   {number}    [params.page]     Page number, zero indexed.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.resource.getAll(...args);
   }
 
   /**
-   * Options object for the Rest Client instance.
+   * Update an Auth0 client grant.
+   *
+   * @example
+   * var data = {
+   *   client_id: CLIENT_ID,
+   *   audience: AUDIENCE,
+   *   scope: []
+   * };
+   * var params = { id: CLIENT_GRANT_ID };
    *
-   * @type {Object}
+   * management.clientGrants.update(params, data, function (err, grant) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(grant.id);
+   * });
+   * @param   {object}    params     Client parameters.
+   * @param   {string}    params.id  Client grant ID.
+   * @param   {object}    data       Updated client data.
+   * @param   {Function}  [cb]       Callback function.
+   * @returns    {Promise|undefined}
    */
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  update(...args) {
+    return this.resource.patch(...args);
+  }
 
   /**
-   * Provides an abstraction layer for consuming the
-   * {@link https://auth0.com/docs/api/v2#!/Client_Grants Auth0 Client Grants endpoint}.
+   * Delete an Auth0 client grant.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.clientGrants.delete({ id: GRANT_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Grant deleted.
+   * });
+   * @param   {object}    params     Client parameters.
+   * @param   {string}    params.id  Client grant ID.
+   * @param   {Function}  [cb]       Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/client-grants/:id',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
-
-/**
- * Create an Auth0 client grant.
- *
- * @method    create
- * @memberOf  module:management.ClientGrantsManager.prototype
- *
- * @example
- * management.clientGrants.create(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Client grant created.
- * });
- *
- * @param   {Object}    data     The client data object.
- * @param   {Function}  [cb]     Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(ClientGrantsManager, 'create', 'resource.create');
-
-/**
- * Get all Auth0 Client Grants.
- *
- * @method    getAll
- * @memberOf  module:management.ClientGrantsManager.prototype
- *
- * @example <caption>
- *   This method takes an optional object as first argument that may be used to
- *   specify pagination settings. If pagination options are not present,
- *   the first page of a limited number of results will be returned.
- * </caption>
- *
- * // Pagination settings.
- * var params = {
- *   per_page: 10,
- *   page: 0
- * };
- *
- *
- * management.clientGrants.getAll(params, function (err, grants) {
- *   console.log(grants.length);
- * });
- *
- * @param   {Object}    [params]          Client Grants parameters.
- * @param   {Number}    [params.per_page] Number of results per page.
- * @param   {Number}    [params.page]     Page number, zero indexed.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(ClientGrantsManager, 'getAll', 'resource.getAll');
-
-/**
- * Update an Auth0 client grant.
- *
- * @method    update
- * @memberOf  module:management.ClientGrantsManager.prototype
- *
- * @example
- * var data = {
- *   client_id: CLIENT_ID,
- *   audience: AUDIENCE,
- *   scope: []
- * };
- * var params = { id: CLIENT_GRANT_ID };
- *
- * management.clientGrants.update(params, data, function (err, grant) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(grant.id);
- * });
- *
- * @param   {Object}    params     Client parameters.
- * @param   {String}    params.id  Client grant ID.
- * @param   {Object}    data       Updated client data.
- * @param   {Function}  [cb]       Callback function.
- *
- * @return    {Promise|undefined}
- */
-utils.wrapPropertyMethod(ClientGrantsManager, 'update', 'resource.patch');
-
-/**
- * Delete an Auth0 client grant.
- *
- * @method    delete
- * @memberOf  module:management.ClientGrantsManager.prototype
- *
- * @example
- * management.clientGrants.delete({ id: GRANT_ID }, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Grant deleted.
- * });
- *
- * @param   {Object}    params     Client parameters.
- * @param   {String}    params.id  Client grant ID.
- * @param   {Function}  [cb]       Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(ClientGrantsManager, 'delete', 'resource.delete');
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+}
 
 module.exports = ClientGrantsManager;
 
@@ -216,7 +176,7 @@

management/ClientGrantsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_ClientsManager.js.html b/docs/management_ClientsManager.js.html index ee848a5a2..56a434736 100644 --- a/docs/management_ClientsManager.js.html +++ b/docs/management_ClientsManager.js.html @@ -24,7 +24,8 @@
@@ -39,13 +40,10 @@

management/ClientsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
 
 /**
- * @class ClientsManager
  * Auth0 Clients Manager.
  *
  * {@link https://auth0.com/docs/api/v2#!/Clients Clients} represent
@@ -53,177 +51,177 @@ 

management/ClientsManager.js

* You can learn more about this in the * {@link https://auth0.com/docs/applications Applications} section of the * documentation. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var ClientsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide client options'); +class ClientsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Clients Auth0 Clients endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/clients/:client_id'); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/management/v2#!/Clients/post_rotate_secret Auth0 Clients Rotate a client secret}. + * + * @type {external:RestClient} + */ + this.rotateSecretResource = this._getRestClient('/clients/:client_id/rotate-secret'); } - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Create an Auth0 client. + * + * @example + * management.clients.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Client created. + * }); + * @param {object} data The client data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Get all Auth0 clients. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.clients.getAll(params, function (err, clients) { + * console.log(clients.length); + * }); + * @param {object} [params] Clients parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); } /** - * Options object for the Rest Client instance. + * Get an Auth0 client. * - * @type {Object} + * @example + * management.clients.get({ client_id: CLIENT_ID }, function (err, client) { + * if (err) { + * // Handle error. + * } + * + * console.log(client); + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {string} params.fields Comma-separated list of fields to include or exclude (based on value provided for include_fields). + * @param {string} params.include_fields Whether specified fields are to be included (true) or excluded (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + get(...args) { + return this.resource.get(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Clients Auth0 Clients endpoint}. + * Update an Auth0 client. + * + * @example + * var data = { name: 'newClientName' }; + * var params = { client_id: CLIENT_ID }; + * + * management.clients.update(params, data, function (err, client) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * console.log(client.name); // 'newClientName' + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {object} data Updated client data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/clients/:client_id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; + update(...args) { + return this.resource.patch(...args); + } -/** - * Create an Auth0 client. - * - * @method create - * @memberOf module:management.ClientsManager.prototype - * - * @example - * management.clients.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client created. - * }); - * - * @param {Object} data The client data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'create', 'resource.create'); + /** + * Delete an Auth0 client. + * + * @example + * management.clients.delete({ client_id: CLIENT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Client deleted. + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } -/** - * Get all Auth0 clients. - * - * @method getAll - * @memberOf module:management.ClientsManager.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.clients.getAll(params, function (err, clients) { - * console.log(clients.length); - * }); - * - * @param {Object} [params] Clients parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'getAll', 'resource.getAll'); + /** + * Rotate a client secret + * + * @example + * management.clients.rotateClientSecret({ client_id: CLIENT_ID }, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Client secret rotated. + * }); + * @param {object} params params object + * @param {string} params.client_id Application client ID. + * @returns {Promise|undefined} + */ + rotateClientSecret(params, cb) { + const query = params || {}; -/** - * Get an Auth0 client. - * - * @method get - * @memberOf module:management.ClientsManager.prototype - * - * @example - * management.clients.get({ client_id: CLIENT_ID }, function (err, client) { - * if (err) { - * // Handle error. - * } - * - * console.log(client); - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'get', 'resource.get'); + // Require a client ID. + if (!params.client_id) { + throw new ArgumentError('The client_id cannot be null or undefined'); + } -/** - * Update an Auth0 client. - * - * @method update - * @memberOf module:management.ClientsManager.prototype - * - * @example - * var data = { name: 'newClientName' }; - * var params = { client_id: CLIENT_ID }; - * - * management.clients.update(params, data, function (err, client) { - * if (err) { - * // Handle error. - * } - * - * console.log(client.name); // 'newClientName' - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Object} data Updated client data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'update', 'resource.patch'); + if (cb && cb instanceof Function) { + return this.rotateSecretResource.create(query, {}, cb); + } -/** - * Delete an Auth0 client. - * - * @method delete - * @memberOf module:management.ClientsManager.prototype - * - * @example - * management.clients.delete({ client_id: CLIENT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client deleted. - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'delete', 'resource.delete'); + return this.rotateSecretResource.create(query, {}); + } +} module.exports = ClientsManager;
@@ -238,7 +236,7 @@

management/ClientsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_ConnectionsManager.js.html b/docs/management_ConnectionsManager.js.html index 15c95b0b1..58b0ea898 100644 --- a/docs/management_ConnectionsManager.js.html +++ b/docs/management_ConnectionsManager.js.html @@ -24,7 +24,8 @@
@@ -39,185 +40,212 @@

management/ConnectionsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
 
 /**
- * @class ConnectionsManager
  * Represents the relationship between Auth0 and an Identity provider.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var ConnectionsManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide client options');
+class ConnectionsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/v2#!/ConnectionsManagers Auth0
+     *  Connections}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/connections/:id');
+
+    this.status = this._getRestClient('/connections/:id/status');
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/management/v2#!/Connections/delete_users_by_email
+     * endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.user = this._getRestClient('/connections/:id/users');
   }
 
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
+  /**
+   * Create a new connection.
+   *
+   * @example
+   * management.connections.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Connection created.
+   * });
+   * @param   {object}    data     Connection data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.resource.create(...args);
   }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+  /**
+   * Get all connections.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   *
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   * management.connections.getAll(params, function (err, connections) {
+   *   console.log(connections.length);
+   * });
+   * @param   {object}    [params]          Connections params.
+   * @param   {number}    [params.per_page] Number of results per page.
+   * @param   {number}    [params.page]     Page number, zero indexed.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.resource.getAll(...args);
   }
 
   /**
-   * Options object for the Rest Client instance.
+   * Get an Auth0 connection.
+   *
+   * @example
+   * management.connections.get({ id: CONNECTION_ID }, function (err, connection) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
    *
-   * @type {Object}
+   *   console.log(connection);
+   * });
+   * @param   {object}    params          Connection parameters.
+   * @param   {string}    params.id       Connection ID.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  get(...args) {
+    return this.resource.get(...args);
+  }
 
   /**
-   * Provides an abstraction layer for performing CRUD operations on
-   * {@link https://auth0.com/docs/api/v2#!/ConnectionsManagers Auth0
-   *  Connections}.
+   * Update an existing connection.
+   *
+   * @example
+   * var data = { name: 'newConnectionName' };
+   * var params = { id: CONNECTION_ID };
+   *
+   * management.connections.update(params, data, function (err, connection) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
    *
-   * @type {external:RestClient}
+   *   console.log(connection.name);  // 'newConnectionName'
+   * });
+   * @param   {object}    params        Connection parameters.
+   * @param   {string}    params.id     Connection ID.
+   * @param   {object}    data          Updated connection data.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns    {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/connections/:id ',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
+  update(...args) {
+    return this.resource.patch(...args);
+  }
 
-/**
- * Create a new connection.
- *
- * @method    create
- * @memberOf  module:management.ConnectionsManager.prototype
- *
- * @example
- * management.connections.create(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Conection created.
- * });
- *
- * @param   {Object}    data     Connection data object.
- * @param   {Function}  [cb]     Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(ConnectionsManager, 'create', 'resource.create');
+  /**
+   * Delete an existing connection.
+   *
+   * @example
+   * management.connections.delete({ id: CONNECTION_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Connection deleted.
+   * });
+   * @param   {object}    params          Connection parameters.
+   * @param   {string}    params.id       Connection ID.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
+   */
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
 
-/**
- * Get all connections.
- *
- * @method    getAll
- * @memberOf  module:management.ConnectionsManager.prototype
- *
- * @example <caption>
- *   This method takes an optional object as first argument that may be used to
- *   specify pagination settings. If pagination options are not present,
- *   the first page of a limited number of results will be returned.
- * </caption>
- *
- * // Pagination settings.
- * var params = {
- *   per_page: 10,
- *   page: 0
- * };
- *
- * management.connections.getAll(params, function (err, connections) {
- *   console.log(connections.length);
- * });
- *
- * @param   {Object}    [params]          Connections params.
- * @param   {Number}    [params.per_page] Number of results per page.
- * @param   {Number}    [params.page]     Page number, zero indexed.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(ConnectionsManager, 'getAll', 'resource.getAll');
+  /**
+   * Checks the status of an ad/ldap connection referenced by its ID.
+   *
+   * @example
+   * var params = {id : 'CONNECTION_ID'}
+   * @example <caption>
+   *   This methods takes the connection ID and returns the status when online, or an error when offline.
+   * </caption>
+   *
+   * management.connections.checkStatus( {id : 'CONNECTION_ID'}, function (err, status) {
+   *   if (err) {
+   *     console.log('OFFLINE', err);
+   *   } else {
+   *     console.log('ONLINE', status);
+   *   }
+   * });
+   * @param   {object}    params              Connection parameters
+   * @param   {string}    params.id           ID of the Connection.
+   * @param   {Function}  [cb]                Callback function.
+   * @returns  {Promise|undefined}
+   */
+  checkStatus(...args) {
+    return this.status.get(...args);
+  }
 
-/**
- * Get an Auth0 connection.
- *
- * @method    get
- * @memberOf  module:management.ConnectionsManager.prototype
- *
- * @example
- * management.connections.get({ id: CONNECTION_ID }, function (err, connection) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(connection);
- * });
- *
- * @param   {Object}    params          Connection parameters.
- * @param   {String}    params.id       Connection ID.
- * @param   {Function}  [cb]            Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(ConnectionsManager, 'get', 'resource.get');
+  /**
+   * Delete a connection user by email.
+   *
+   * @example
+   * management.connections.deleteUserByEmail({ id: CONNECTION_ID, email:USER_EMAIL }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // User deleted.
+   * });
+   * @param   {object}    params          Connection parameters.
+   * @param   {string}    params.id       Connection ID.
+   * @param   {string}    params.email    User Email.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
+   */
+  deleteUserByEmail(params, cb) {
+    if (typeof params !== 'object' || typeof params.email !== 'string' || params.email.length < 1) {
+      throw new ArgumentError('You must provide an email for the deleteUserByEmail method');
+    }
 
-/**
- * Update an existing connection.
- *
- * @method    update
- * @memberOf  module:management.ConnectionsManager.prototype
- *
- * @example
- * var data = { name: 'newConnectionName' };
- * var params = { id: CONNECTION_ID };
- *
- * management.connections.update(params, data, function (err, connection) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(connection.name);  // 'newConnectionName'
- * });
- *
- * @param   {Object}    params        Conneciton parameters.
- * @param   {String}    params.id     Connection ID.
- * @param   {Object}    data          Updated connection data.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return    {Promise|undefined}
- */
-utils.wrapPropertyMethod(ConnectionsManager, 'update', 'resource.patch');
+    if (!params.id) {
+      throw new ArgumentError('The connection id cannot be null or undefined');
+    }
 
-/**
- * Delete an existing connection.
- *
- * @method    delete
- * @memberOf  module:management.ConnectionsManager.prototype
- *
- * @example
- * management.connections.delete({ id: CONNECTION_ID }, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Conection deleted.
- * });
- *
- * @param   {Object}    params          Connection parameters.
- * @param   {String}    params.id       Connection ID.
- * @param   {Function}  [cb]            Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(ConnectionsManager, 'delete', 'resource.delete');
+    if (cb && cb instanceof Function) {
+      return this.user.delete(params, {}, cb);
+    }
+
+    return this.user.delete(params, {});
+  }
+}
 
 module.exports = ConnectionsManager;
 
@@ -232,7 +260,7 @@

management/ConnectionsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_CustomDomainsManager.js.html b/docs/management_CustomDomainsManager.js.html index 09e419d59..c96b52690 100644 --- a/docs/management_CustomDomainsManager.js.html +++ b/docs/management_CustomDomainsManager.js.html @@ -24,7 +24,8 @@
@@ -39,13 +40,10 @@

management/CustomDomainsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
 
 /**
- * @class CustomDomainsManager
  * Auth0 Custom Domains Manager.
  *
  * {@link https://auth0.com/docs/api/management/v2#!/Custom_Domains/get_custom_domains CustomDomains} represent
@@ -53,180 +51,134 @@ 

management/CustomDomainsManager.js

* You can learn more about this in the * {@link https://auth0.com/docs/custom-domains CustomDomains} section of the * documentation. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var CustomDomainsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); - } - - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); +class CustomDomainsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/custom-domains/:id'); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains Verify endpoint}. + * + * @type {external:RestClient} + */ + this.vefifyResource = this._getRestClient('/custom-domains/:id/verify'); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Create an Auth0 Custom Domain. + * + * @example + * management.customDomains.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // CustomDomain created. + * }); + * @param {object} data The custom domain data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); } /** - * Options object for the Rest Client instance. + * Get all Auth0 CustomDomains. * - * @type {Object} + * @example + * management.customDomains.getAll(function (err, customDomains) { + * console.log(customDomains.length); + * }); + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + getAll(...args) { + return this.resource.getAll(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains endpoint}. + * Get a Custom Domain. + * + * @example + * management.customDomains.get({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * console.log(customDomain); + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0CustomDomainsRestClient = new Auth0RestClient( - options.baseUrl + '/custom-domains/:id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0CustomDomainsRestClient, options.retry); + get(...args) { + return this.resource.get(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains Verify endpoint}. + * Verify a Custom Domain. + * + * @example + * management.customDomains.verify({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * console.log(customDomain); + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0VerifyRestClient = new Auth0RestClient( - options.baseUrl + '/custom-domains/:id/verify', - clientOptions, - options.tokenProvider - ); - this.vefifyResource = new RetryRestClient(auth0VerifyRestClient, options.retry); -}; - -/** - * Create an Auth0 Custom Domain. - * - * @method create - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // CustomDomain created. - * }); - * - * @param {Object} data The custom domain data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(CustomDomainsManager, 'create', 'resource.create'); - -/** - * Get all Auth0 CustomDomains. - * - * @method getAll - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.getAll(function (err, customDomains) { - * console.log(customDomains.length); - * }); - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(CustomDomainsManager, 'getAll', 'resource.getAll'); + verify(params, cb) { + if (!params || !params.id) { + throw new ArgumentError('The custom domain id cannot be null or undefined'); + } -/** - * Get a Custom Domain. - * - * @method get - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.get({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { - * if (err) { - * // Handle error. - * } - * - * console.log(customDomain); - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(CustomDomainsManager, 'get', 'resource.get'); + if (cb && cb instanceof Function) { + return this.vefifyResource.create(params, {}, cb); + } -/** - * Verify a Custom Domain. - * - * @method verify - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.verify({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { - * if (err) { - * // Handle error. - * } - * - * console.log(customDomain); - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -CustomDomainsManager.prototype.verify = function(params, cb) { - if (!params || !params.id) { - throw new ArgumentError('The custom domain id cannot be null or undefined'); + return this.vefifyResource.create(params, {}); } - if (cb && cb instanceof Function) { - return this.vefifyResource.create(params, {}, cb); + /** + * Delete a Custom Domain. + * + * @example + * management.customDomains.delete({ id: CUSTOM_DOMAIN_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // CustomDomain deleted. + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); } - - return this.vefifyResource.create(params, {}); -}; - -/** - * Delete a Custom Domain. - * - * @method delete - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.delete({ id: CUSTOM_DOMAIN_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // CustomDomain deleted. - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(CustomDomainsManager, 'delete', 'resource.delete'); +} module.exports = CustomDomainsManager;
@@ -241,7 +193,7 @@

management/CustomDomainsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_DeviceCredentialsManager.js.html b/docs/management_DeviceCredentialsManager.js.html index f5dc2e012..7c615142a 100644 --- a/docs/management_DeviceCredentialsManager.js.html +++ b/docs/management_DeviceCredentialsManager.js.html @@ -24,7 +24,8 @@
@@ -39,130 +40,95 @@

management/DeviceCredentialsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-/**
- * @class DeviceCredentialsManager
  * Manages Auth0 Device Credentials.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var DeviceCredentialsManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide manager options');
-  }
-
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
+class DeviceCredentialsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Options object for the RestClient instance.
+     *
+     * @type {object}
+     */
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Device_Credentials
+     *  Auth0 DeviceCredentialsManagers endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/device-credentials/:id');
   }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+  /**
+   * Create an Auth0 credential.
+   *
+   * @example
+   * management.deviceCredentials.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Credential created.
+   * });
+   * @param   {object}    data     The device credential data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  createPublicKey(...args) {
+    return this.resource.create(...args);
   }
 
   /**
-   * Options object for the RestClient instance.
+   * Get all Auth0 credentials.
+   *
+   * @example
+   * var params = {user_id: "USER_ID"};
    *
-   * @type {Object}
+   * management.deviceCredentials.getAll(params, function (err, credentials) {
+   *   console.log(credentials.length);
+   * });
+   * @param   {object}    params  Credential parameters.
+   * @param   {Function}  [cb]    Callback function.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
 
   /**
-   * Provides an abstraction layer for consuming the
-   * {@link https://auth0.com/docs/api/v2#!/Device_Credentials
-   *  Auth0 DeviceCredentialsManagers endpoint}.
+   * Delete an Auth0 device credential.
    *
-   * @type {external:RestClient}
+   * @example
+   * var params = { id: CREDENTIAL_ID };
+   *
+   * management.deviceCredentials.delete(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Credential deleted.
+   * });
+   * @param   {object}    params          Credential parameters.
+   * @param   {string}    params.id       Device credential ID.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/device-credentials/:id',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
-
-/**
- * Create an Auth0 credential.
- *
- * @method    create
- * @memberOf  module:management.DeviceCredentialsManager.prototype
- *
- * @example
- * management.deviceCredentials.create(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Credential created.
- * });
- *
- * @param   {Object}    data     The device credential data object.
- * @param   {Function}  [cb]     Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(DeviceCredentialsManager, 'createPublicKey', 'resource.create');
-
-/**
- * Get all Auth0 credentials.
- *
- * @method  getAll
- * @memberOf  module:management.DeviceCredentialsManager.prototype
- *
- * @example
- * management.deviceCredentials.getAll(function (err, credentials) {
- *   console.log(credentials.length);
- * });
- *
- * @param   {Function}  [cb]    Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(DeviceCredentialsManager, 'getAll', 'resource.getAll');
-
-/**
- * Delete an Auth0 device credential.
- *
- * @method    delete
- * @memberOf  module:management.DeviceCredentialsManager.prototype
- *
- * @example
- * var params = { id: CREDENTIAL_ID };
- *
- * management.deviceCredentials.delete(params, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Credential deleted.
- * });
- *
- * @param   {Object}    params          Credential parameters.
- * @param   {String}    params.id       Device credential ID.
- * @param   {Function}  [cb]            Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(DeviceCredentialsManager, 'delete', 'resource.delete');
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+}
 
 module.exports = DeviceCredentialsManager;
 
@@ -177,7 +143,7 @@

management/DeviceCredentialsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_EmailProviderManager.js.html b/docs/management_EmailProviderManager.js.html index 38f961049..dc428201b 100644 --- a/docs/management_EmailProviderManager.js.html +++ b/docs/management_EmailProviderManager.js.html @@ -24,7 +24,8 @@
@@ -39,148 +40,105 @@

management/EmailProviderManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-/**
- * @class EmailProviderManager
  * Auth0 Email Provider.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var EmailProviderManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide client options');
+class EmailProviderManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * [Auth0 Clients endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/emails/provider');
   }
 
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
+  /**
+   * Configure the email provider.
+   *
+   * @example
+   * management.emailProvider.configure(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Email provider configured.
+   * });
+   * @param   {object}    data     The email provider data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  configure(...args) {
+    return this.resource.create(...args);
   }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+  /**
+   * Get the email provider.
+   *
+   * @example
+   * management.emailProvider.get(function (err, provider) {
+   *   console.log(provider);
+   * });
+   * @param   {Function}  [cb]    Callback function.
+   * @param   {object}    [params]          Clients parameters.
+   * @param   {number}    [params.fields] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields.
+   * @param   {number}    [params.include_fields]  true if the fields specified are to be excluded from the result, false otherwise (defaults to true)
+   * @returns  {Promise|undefined}
+   */
+  get(...args) {
+    return this.resource.getAll(...args);
   }
 
   /**
-   * Options object for the Rest Client instance.
+   * Update the email provider.
+   *
+   * @example
+   * management.emailProvider.update(params, data, function (err, provider) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
    *
-   * @type {Object}
+   *   // Updated email provider.
+   *   console.log(provider);
+   * });
+   * @param   {object}    params            Email provider parameters.
+   * @param   {object}    data              Updated email provider data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
    */
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  update(...args) {
+    return this.resource.patch(...args);
+  }
 
   /**
-   * Provides an abstraction layer for consuming the
-   * [Auth0 Clients endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
+   * Delete email provider.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.emailProvider.delete(function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Email provider configured.
+   * });
+   * @param   {Function}  [cb]    Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/emails/provider',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
-
-/**
- * Configure the email provider.
- *
- * @method    configure
- * @memberOf  module:management.EmailProviderManager.prototype
- *
- * @example
- * management.emailProvider.configure(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Email provider configured.
- * });
- * @param   {Object}    data     The email provider data object.
- * @param   {Function}  [cb]     Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(EmailProviderManager, 'configure', 'resource.create');
-
-/**
- * Get the email provider.
- *
- * @method    get
- * @memberOf  module:management.EmailProviderManager.prototype
- *
- * @example
- * management.emailProvider.get(function (err, provider) {
- *   console.log(provider);
- * });
- *
- * @param   {Function}  [cb]    Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(EmailProviderManager, 'get', 'resource.getAll');
-
-/**
- * Update the email provider.
- *
- * @method    update
- * @memberOf  module:management.EmailProviderManager.prototype
- *
- * @example
- * management.emailProvider.update(params, data, function (err, provider) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Updated email provider.
- *   console.log(provider);
- * });
- *
- * @param   {Object}    params            Email provider parameters.
- * @param   {Object}    data              Updated email provider data.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return    {Promise|undefined}
- */
-utils.wrapPropertyMethod(EmailProviderManager, 'update', 'resource.patch');
-
-/**
- * Delete email provider.
- *
- * @method    delete
- * @memberOf  module:management.EmailProviderManager.prototype
- *
- * @example
- * management.emailProvider.delete(function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Email provider configured.
- * });
- *
- * @param   {Function}  [cb]    Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(EmailProviderManager, 'delete', 'resource.delete');
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+}
 
 module.exports = EmailProviderManager;
 
@@ -195,7 +153,7 @@

management/EmailProviderManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_EmailTemplatesManager.js.html b/docs/management_EmailTemplatesManager.js.html index b926f4b92..814ed8699 100644 --- a/docs/management_EmailTemplatesManager.js.html +++ b/docs/management_EmailTemplatesManager.js.html @@ -24,7 +24,8 @@
@@ -39,133 +40,94 @@

management/EmailTemplatesManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-/**
- * @class EmailTemplatesManager
  * This class provides a simple abstraction for performing CRUD operations
- * on Auth0's Email Templates. {@see https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName}
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
+ * on Auth0's Email Templates. {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName}
  */
-var EmailTemplatesManager = function(options) {
-  if (!options || 'object' !== typeof options) {
-    throw new ArgumentError('Must provide manager options');
+class EmailTemplatesManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName Auth0's Email Templates}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/email-templates/:name');
   }
 
-  if (!options.baseUrl || 'string' !== typeof options.baseUrl) {
-    throw new ArgumentError('Must provide a valid string as base URL for the API');
+  /**
+   * Create a new Email Template.
+   *
+   * @example
+   * management.emailTemplates.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Email Template created.
+   * });
+   * @param   {object}    data     Email Template data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.resource.create(...args);
   }
 
   /**
-   * Options object for the Rest Client instance.
+   * Get an Auth0 Email Template.
    *
-   * @type {Object}
+   * @example
+   * management.emailTemplates.get({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(emailTemplate);
+   * });
+   * @param   {object}    params          Email Template parameters.
+   * @param   {string}    params.name     Template Name
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  get(...args) {
+    return this.resource.get(...args);
+  }
 
   /**
-   * Provides an abstraction layer for performing CRUD operations on
-   * {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName Auth0's Email Templates}.
+   * Update an existing Email Template.
+   *
+   * @example
+   * var data = { from: 'new@email.com' };
+   * var params = { name: EMAIL_TEMPLATE_NAME };
    *
-   * @type {external:RestClient}
+   * management.emailTemplates.update(params, data, function (err, emailTemplate) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(emailTemplate.from);  // 'new@email.com'
+   * });
+   * @param   {object}    params          Email Template parameters.
+   * @param   {string}    params.name     Template Name
+   * @param   {object}    data            Updated Email Template data.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/email-templates/:name',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
-
-/**
- * Create a new Email Template.
- *
- * @method    create
- * @memberOf  module:management.EmailTemplatesManager.prototype
- *
- * @example
- * management.emailTemplates.create(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Email Template created.
- * });
- *
- * @param   {Object}    data     Email Template data object.
- * @param   {Function}  [cb]     Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(EmailTemplatesManager, 'create', 'resource.create');
-
-/**
- * Get an Auth0 Email Template.
- *
- * @method    get
- * @memberOf  module:management.EmailTemplatesManager.prototype
- *
- * @example
- * management.emailTemplates.get({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(emailTemplate);
- * });
- *
- * @param   {Object}    params          Email Template parameters.
- * @param   {String}    params.name     Template Name
- * @param   {Function}  [cb]            Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(EmailTemplatesManager, 'get', 'resource.get');
-
-/**
- * Update an existing Email Template.
- *
- * @method    update
- * @memberOf  module:management.EmailTemplatesManager.prototype
- *
- * @example
- * var data = { from: 'new@email.com' };
- * var params = { name: EMAIL_TEMPLATE_NAME };
- *
- * management.emailTemplates.update(params, data, function (err, emailTemplate) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(emailTemplate.from);  // 'new@email.com'
- * });
- *
- * @param   {Object}    params          Email Template parameters.
- * @param   {String}    params.name     Template Name
- * @param   {Object}    data            Updated Email Template data.
- * @param   {Function}  [cb]            Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(EmailTemplatesManager, 'update', 'resource.patch');
+  update(...args) {
+    return this.resource.patch(...args);
+  }
+}
 
 module.exports = EmailTemplatesManager;
 
@@ -180,7 +142,7 @@

management/EmailTemplatesManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_GrantsManager.js.html b/docs/management_GrantsManager.js.html new file mode 100644 index 000000000..dc8683cfb --- /dev/null +++ b/docs/management_GrantsManager.js.html @@ -0,0 +1,145 @@ + + + + + + management/GrantsManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/GrantsManager.js

+ + + + + + + +
+
+
const BaseManager = require('./BaseManager');
+
+/**
+ * Auth0 Grants Manager.
+ *
+ * See {@link https://auth0.com/docs/api/v2#!/Grants Grants}
+ */
+class GrantsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Grants Auth0 Grants endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/grants/:id');
+  }
+
+  /**
+   * Get all Auth0 Grants.
+   *
+   * @example
+   * var params = {
+   *   per_page: 10,
+   *   page: 0,
+   *   include_totals: true,
+   *   user_id: 'USER_ID',
+   *   client_id: 'CLIENT_ID',
+   *   audience: 'AUDIENCE'
+   * };
+   *
+   * management.getGrants(params, function (err, grants) {
+   *   console.log(grants.length);
+   * });
+   * @param   {object}    params                Grants parameters.
+   * @param   {number}    params.per_page       Number of results per page.
+   * @param   {number}    params.page           Page number, zero indexed.
+   * @param   {boolean}   params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
+   * @param   {string}    params.user_id        The user_id of the grants to retrieve.
+   * @param   {string}    params.client_id      The client_id of the grants to retrieve.
+   * @param   {string}    params.audience       The audience of the grants to retrieve.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
+
+  /**
+   * Delete an Auth0 grant.
+   *
+   * @example
+   * var params = {
+   *    id: 'GRANT_ID',
+   *    user_id: 'USER_ID'
+   * };
+   *
+   * management.deleteGrant(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Grant deleted.
+   * });
+   * @param   {object}    params         Grant parameters.
+   * @param   {string}    params.id      Grant ID.
+   * @param   {string}    params.user_id The user_id of the grants to delete.
+   * @param   {Function}  [cb]           Callback function.
+   * @returns  {Promise|undefined}
+   */
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+}
+
+module.exports = GrantsManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_GuardianManager.js.html b/docs/management_GuardianManager.js.html index fd969d25b..b9c5c8962 100644 --- a/docs/management_GuardianManager.js.html +++ b/docs/management_GuardianManager.js.html @@ -24,7 +24,8 @@
@@ -39,281 +40,365 @@

management/GuardianManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-/**
- * @class
  * Abstracts interaction with the Guardian endpoint.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var GuardianManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide manager options');
+class GuardianManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian enrollments.
+     *
+     * @type {external:RestClient}
+     */
+    this.enrollments = this._getRestClient('/guardian/enrollments/:id');
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian tickets.
+     *
+     * @type {external:RestClient}
+     */
+    this.tickets = this._getRestClient('/guardian/enrollments/ticket');
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian factors.
+     *
+     * @type {external:RestClient}
+     */
+    this.factors = this._getRestClient('/guardian/factors/:name');
+
+    /**
+     * Provides an abstraction layer for configuring Factor settings
+     *
+     * @type {external:RestClient}
+     */
+    this.factorSettings = this._getRestClient('/guardian/factors/:name/settings');
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian factor templates.
+     *
+     * @type {external:RestClient}
+     */
+    this.factorsTemplates = this._getRestClient('/guardian/factors/:name/templates');
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian factor providers.
+     *
+     * @type {external:RestClient}
+     */
+    this.factorsProviders = this._getRestClient('/guardian/factors/:name/providers/:provider');
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian policies.
+     *
+     * @type {external:RestClient}
+     */
+    this.policies = this._getRestClient('/guardian/policies');
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian phone factor selected provider.
+     *
+     * @type {external:RestClient}
+     */
+    this.factorsPhoneSelectedProvider = this._getRestClient(
+      '/guardian/factors/sms/selected-provider'
+    );
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian phone factor message types.
+     *
+     * @type {external:RestClient}
+     */
+    this.factorsPhoneMessageTypes = this._getRestClient('/guardian/factors/phone/message-types');
   }
 
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
+  /**
+   * Get a single Guardian enrollment.
+   *
+   * @example
+   * management.guardian.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) {
+   *   console.log(enrollment);
+   * });
+   * @param   {object}    data      The user data object.
+   * @param   {string}    data.id   The user id.
+   * @param   {Function}  [cb]      Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getGuardianEnrollment(...args) {
+    return this.enrollments.get(...args);
   }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+  /**
+   * Delete a Guardian enrollment.
+   *
+   * @example
+   * management.guardian.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollments) {
+   *   console.log(enrollments);
+   * });
+   * @param   {object}    data      The user data object.
+   * @param   {string}    data.id   The user id.
+   * @param   {Function}  [cb]      Callback function.
+   * @returns  {Promise|undefined}
+   */
+  deleteGuardianEnrollment(...args) {
+    return this.enrollments.delete(...args);
   }
 
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  /**
+   * Create a Guardian enrollment ticket.
+   *
+   * @example
+   * management.guardian.createEnrollmentTicket(function (err, ticket) {
+   *   console.log(ticket);
+   * });
+   * @param   {Function}  [cb]      Callback function.
+   * @returns  {Promise|undefined}
+   */
+  createEnrollmentTicket(...args) {
+    return this.tickets.create(...args);
+  }
 
   /**
-   * Provides an abstraction layer for retrieving Guardian enrollments.
+   * Get a list of factors and statuses.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.guardian.getFactors(function (err, factors) {
+   *   console.log(factors.length);
+   * });
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
    */
-  var guardianEnrollmentsAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/guardian/enrollments/:id',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.enrollments = new RetryRestClient(guardianEnrollmentsAuth0RestClient, options.retry);
+  getFactors(...args) {
+    return this.factors.getAll(...args);
+  }
 
   /**
-   * Provides an abstraction layer for retrieving Guardian tickets.
+   * Get Guardian factor configuration
    *
-   * @type {external:RestClient}
+   * @example
+   * management.guardian.getFactorSettings({ name: 'webauthn-roaming' }, function (err, settings) {
+   *   console.log(settings);
+   * });
+   * @param   {object}    params            Factor  parameters.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
    */
-  var guardianTicketsAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/guardian/enrollments/ticket',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.tickets = new RetryRestClient(guardianTicketsAuth0RestClient, options.retry);
+  getFactorSettings(...args) {
+    return this.factorSettings.get(...args);
+  }
 
   /**
-   * Provides an abstraction layer for retrieving Guardian factors.
+   * Update Guardian factor configuration
    *
-   * @type {external:RestClient}
+   * @example
+   * management.guardian.updateFactorSettings(
+   *  { name: 'webauthn-roaming' },
+   *  { userVerification: 'discouraged', overrideRelyingParty: false },
+   *  function (err, settings) {
+   *   console.log(settings);
+   * });
+   * @param   {object}    params            Factor  parameters.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
    */
-  var guardianFactorsAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/guardian/factors/:name',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.factors = new RetryRestClient(guardianFactorsAuth0RestClient, options.retry);
+  updateFactorSettings(...args) {
+    return this.factorSettings.update(...args);
+  }
 
   /**
-   * Provides an abstraction layer for retrieving Guardian factors.
+   * Get Guardian factor provider configuration
    *
-   * @type {external:RestClient}
+   * @example
+   * management.guardian.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) {
+   *   console.log(provider);
+   * });
+   * @param   {object}    params            Factor provider parameters.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
    */
-  var guardianFactorsTemplatesAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/guardian/factors/:name/templates',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.factorsTemplates = new RetryRestClient(
-    guardianFactorsTemplatesAuth0RestClient,
-    options.retry
-  );
+  getFactorProvider(...args) {
+    return this.factorsProviders.get(...args);
+  }
 
   /**
-   * Provides an abstraction layer for retrieving Guardian factor providers.
+   * Update Guardian's factor provider
    *
-   * @type {external:RestClient}
+   * @example
+   * management.guardian.updateFactorProvider({ name: 'sms', provider: 'twilio' }, {
+   *   messaging_service_sid: 'XXXXXXXXXXXXXX',
+   *   auth_token: 'XXXXXXXXXXXXXX',
+   *   sid: 'XXXXXXXXXXXXXX'
+   * }, function (err, provider) {
+   *   console.log(provider);
+   * });
+   * @param   {object}    params            Factor provider parameters.
+   * @param   {object}    data              Updated Factor provider data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
    */
-  var guardianFactorsProvidersAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/guardian/factors/:name/providers/:provider',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.factorsProviders = new RetryRestClient(
-    guardianFactorsProvidersAuth0RestClient,
-    options.retry
-  );
-};
+  updateFactorProvider(...args) {
+    return this.factorsProviders.update(...args);
+  }
 
-/**
- * Get a single Guardian enrollment.
- *
- * @method    getGuardianEnrollment
- * @memberOf  module:management.GuardianManager.prototype
- *
- * @example
- * management.guardian.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) {
- *   console.log(enrollment);
- * });
- *
- * @param   {Object}    data      The user data object.
- * @param   {String}    data.id   The user id.
- * @param   {Function}  [cb]      Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'getGuardianEnrollment', 'enrollments.get');
+  /**
+   * Get Guardian enrollment and verification factor templates
+   *
+   * @example
+   * management.guardian.getFactorTemplates({ name: 'sms' }, function (err, templates) {
+   *   console.log(templates);
+   * });
+   * @param   {object}    params            Factor parameters.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getFactorTemplates(...args) {
+    return this.factorsTemplates.get(...args);
+  }
 
-/**
- * Delete a Guardian enrollment.
- *
- * @method    deleteGuardianEnrollment
- * @memberOf  module:management.GuardianManager.prototype
- *
- * @example
- * management.guardian.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollments) {
- *   console.log(enrollments);
- * });
- *
- * @param   {Object}    data      The user data object.
- * @param   {String}    data.id   The user id.
- * @param   {Function}  [cb]      Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'deleteGuardianEnrollment', 'enrollments.delete');
+  /**
+   * Update Guardian enrollment and verification factor templates
+   *
+   * @example
+   * management.guardian.updateFactorProvider({ name: 'sms' }, {
+   *   enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.",
+   *   verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}"
+   * }, function (err, templates) {
+   *   console.log(templates);
+   * });
+   * @param   {object}    params            Factor parameters.
+   * @param   {object}    data              Updated factor templates data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  updateFactorTemplates(...args) {
+    return this.factorsTemplates.update(...args);
+  }
 
-/**
- * Create a Guardian enrollment ticket.
- *
- * @method    createEnrollmentTicket
- * @memberOf  module:management.GuardianManager.prototype
- *
- * @example
- * management.guardian.createEnrollmentTicket(function (err, ticket) {
- *   console.log(ticket);
- * });
- *
- * @param   {Function}  [cb]      Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'createEnrollmentTicket', 'tickets.create');
+  /**
+   * Update Guardian Factor
+   *
+   * @example
+   * management.guardian.updateFactor({ name: 'sms' }, {
+   *   enabled: true
+   * }, function (err, factor) {
+   *   console.log(factor);
+   * });
+   * @param   {object}    params            Factor parameters.
+   * @param   {object}    data              Updated factor data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  updateFactor(...args) {
+    return this.factors.update(...args);
+  }
 
-/**
- * Get a list of factors and statuses.
- *
- * @method    getFactors
- * @memberOf  module:management.GuardianManager.prototype
- *
- * management.guardian.getFactors(function (err, factors) {
- *   console.log(factors.length);
- * });
- *
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'getFactors', 'factors.getAll');
+  /**
+   * Get enabled Guardian policies
+   *
+   * @example
+   * management.guardian.getPolicies(function (err, policies) {
+   *   console.log(policies);
+   * });
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getPolicies(...args) {
+    return this.policies.get(...args);
+  }
 
-/**
- * Get Guardian factor provider configuration
- *
- * @method    getFactorProvider
- * @memberOf  module:management.GuardianManager.prototype
- *
- * management.guardian.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) {
- *   console.log(provider);
- * });
- *
- * @param   {Object}    params            Factor provider parameters.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'getFactorProvider', 'factorsProviders.get');
+  /**
+   * Update enabled Guardian policies
+   *
+   * @example
+   * management.guardian.updatePolicies({}, [
+   *   'all-applications'
+   * ], function (err, policies) {
+   *   console.log(policies);
+   * });
+   * @param   {object}    params            Parameters.
+   * @param   {string[]}  data              Policies to enable. Empty array disables all policies.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  updatePolicies(...args) {
+    return this.policies.update(...args);
+  }
 
-/**
- * Update Guardian's factor provider
- *
- * @method    updateFactorProvider
- * @memberOf  module:management.GuardianManager.prototype
- *
- * management.guardian.updateFactorProvider({ name: 'sms', provider: 'twilio' }, {
- *  messaging_service_sid: 'XXXXXXXXXXXXXX',
- *  auth_token: 'XXXXXXXXXXXXXX',
- *  sid: 'XXXXXXXXXXXXXX'
- * }, function(err, provider) {
- *  console.log(provider);
- * });
- *
- * @param   {Object}    params            Factor provider parameters.
- * @param   {Object}    data              Updated Factor provider data.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'updateFactorProvider', 'factorsProviders.update');
+  /**
+   * Get the Guardian phone factor's selected provider
+   *
+   * @example
+   * management.guardian.getPhoneFactorSelectedProvider(function (err, selectedProvider) {
+   *   console.log(selectedProvider);
+   * });
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getPhoneFactorSelectedProvider(...args) {
+    return this.factorsPhoneSelectedProvider.get(...args);
+  }
 
-/**
- * Get Guardian enrollment and verification factor templates
- *
- * @method    getFactorTemplates
- * @memberOf  module:management.GuardianManager.prototype
- *
- * management.guardian.getFactorTemplates({ name: 'sms' }, function (err, templates) {
- *   console.log(templates);
- * });
- *
- * @param   {Object}    params            Factor parameters.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'getFactorTemplates', 'factorsTemplates.get');
+  /**
+   * Update the Guardian phone factor's selected provider
+   *
+   * @example
+   * management.guardian.updatePhoneFactorSelectedProvider({}, {
+   *   provider: 'twilio'
+   * }, function (err, factor) {
+   *   console.log(factor);
+   * });
+   * @param   {object}    params            Parameters.
+   * @param   {object}    data              Updated selected provider data.
+   * @param   {string}    data.provider     Name of the selected provider
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  updatePhoneFactorSelectedProvider(...args) {
+    return this.factorsPhoneSelectedProvider.update(...args);
+  }
 
-/**
- * Update Guardian enrollment and verification factor templates
- *
- * @method    updateFactorTemplates
- * @memberOf  module:management.GuardianManager.prototype
- *
- * management.guardian.updateFactorProvider({ name: 'sms' }, {
- *  enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.",
- *  verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}"
- * }, function(err, templates) {
- *  console.log(templates);
- * });
- *
- * @param   {Object}    params            Factor parameters.
- * @param   {Object}    data              Updated factor templates data.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'updateFactorTemplates', 'factorsTemplates.update');
+  /**
+   * Get the Guardian phone factor's message types
+   *
+   * @example
+   * management.guardian.getPhoneFactorMessageTypes(function (err, messageTypes) {
+   *   console.log(messageTypes);
+   * });
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getPhoneFactorMessageTypes(...args) {
+    return this.factorsPhoneMessageTypes.get(...args);
+  }
 
-/**
- * Update Guardian Factor
- *
- * @method    updateFactor
- * @memberOf  module:management.GuardianManager.prototype
- *
- * management.guardian.updateFactor({ name: 'sms' }, {
- *  enabled: true
- * }, function(err, factor) {
- *  console.log(factor);
- * });
- *
- * @param   {Object}    params            Factor parameters.
- * @param   {Object}    data              Updated factor data.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(GuardianManager, 'updateFactor', 'factors.update');
+  /**
+   * Update the Guardian phone factor's message types
+   *
+   * @example
+   * management.guardian.updatePhoneFactorMessageTypes({}, {
+   *   message_types: ['sms', 'voice']
+   * }, function (err, factor) {
+   *   console.log(factor);
+   * });
+   * @param   {object}    params                Parameters.
+   * @param   {object}    data                  Updated selected provider data.
+   * @param   {string[]}  data.message_types    Message types (only `"sms"` and `"voice"` are supported).
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  updatePhoneFactorMessageTypes(...args) {
+    return this.factorsPhoneMessageTypes.update(...args);
+  }
+}
 
 module.exports = GuardianManager;
 
@@ -328,7 +413,7 @@

management/GuardianManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_HooksManager.js.html b/docs/management_HooksManager.js.html new file mode 100644 index 000000000..c449594b0 --- /dev/null +++ b/docs/management_HooksManager.js.html @@ -0,0 +1,356 @@ + + + + + + management/HooksManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/HooksManager.js

+ + + + + + + +
+
+
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
+
+/**
+ * The hooks manager class provides a simple abstraction for performing CRUD operations
+ * on Auth0 HooksManagers.
+ */
+class HooksManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/v2#!/HooksManagers Auth0 HooksManagers}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/hooks/:id');
+
+    this.secrets = this._getRestClient('/hooks/:id/secrets');
+  }
+
+  /**
+   * Create a new hook.
+   *
+   * @example
+   * management.hooks.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Hook created.
+   * });
+   * @param   {object}    data     Hook data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.resource.create(...args);
+  }
+
+  /**
+   * Get all hooks.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   *
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   * management.hooks.getAll(params, function (err, hooks) {
+   *   console.log(hooks.length);
+   * });
+   * @param   {object}    [params]          Hooks parameters.
+   * @param   {number}    [params.per_page] Number of results per page.
+   * @param   {number}    [params.page]     Page number, zero indexed.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
+
+  /**
+   * Get an Auth0 hook.
+   *
+   * @example
+   * management.hooks.get({ id: HOOK_ID }, function (err, hook) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(hook);
+   * });
+   * @param   {object}    params        Hook parameters.
+   * @param   {string}    params.id     Hook ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  get(...args) {
+    return this.resource.get(...args);
+  }
+
+  /**
+   * Update an existing hook.
+   *
+   * @example
+   * var data = { name: 'New name' };
+   * var params = { id: HOOK_ID };
+   *
+   * // Using auth0 instance.
+   * management.updateHook(params, data, function (err, hook) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(hook.name);  // 'New name'
+   * });
+   *
+   * // Using the hooks manager directly.
+   * management.hooks.update(params, data, function (err, hook) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(hook.name);  // 'New name'
+   * });
+   * @param   {object}    params        Hook parameters.
+   * @param   {string}    params.id     Hook ID.
+   * @param   {object}    data          Updated hook data.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  update(...args) {
+    return this.resource.patch(...args);
+  }
+
+  /**
+   * Delete an existing hook.
+   *
+   * @example
+   * management.hooks.delete({ id: HOOK_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Hook deleted.
+   * });
+   * @param   {object}    params        Hook parameters.
+   * @param   {string}    params.id     Hook ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+
+  /**
+   * Get Hook secrets
+   *
+   * @example <caption>
+   *   This method takes a first argument as the hookId and returns the secrets for the hook. The secret values will be hidden.
+   * </caption>
+   *
+   * var params = {id : 'HOOK_ID'}
+   *
+   * management.hooks.getSecrets( {id : 'HOOK_ID'}, function (err, secrets) {
+   *   console.log(secrets);
+   * });
+   * @param   {object}    params            Hook parameters.
+   * @param   {string}    params.id         ID of the Hook.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getSecrets(params, callback) {
+    return this.secrets.getAll(params, callback);
+  }
+
+  /**
+   * Add secrets in a hook
+   *
+   * @example
+   * var params =  { id :'HOOK_ID'};
+   * var data   = { "DB_USER" :  "jdoe", "DB_PASS": "password123!"};
+   *
+   * management.hooks.addSecrets(params, data, function (err, secrets) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // secrets added.
+   * });
+   * @param   {object}    params        Hook parameters.
+   * @param   {string}    params.id     ID of the Hook.
+   * @param   {object}    data          object containing secrets as key/value pairs
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  addSecrets(params, data, cb) {
+    params = params || {};
+    data = data || {};
+
+    // Require an ID.
+    if (!params.id) {
+      throw new ArgumentError('The id passed in params cannot be null or undefined');
+    }
+
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The hook Id has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.secrets.create(params, data, cb);
+    }
+
+    return this.secrets.create(params, data);
+  }
+
+  /**
+   * Update secrets in a hook
+   *
+   * @example
+   * var params =  { id :'HOOK_ID'};
+   * var data   = { "DB_USER" :  "jdoe", "DB_PASS": "password123!"};
+   *
+   * management.hooks.updateSecrets(params, data, function (err, secrets) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // secrets updated.
+   * });
+   * @param   {object}    params        Hook parameters.
+   * @param   {string}    params.id     ID of the Hook.
+   * @param   {object}    data          object containing secrets as key/value pairs
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  updateSecrets(params, data, cb) {
+    params = params || {};
+    data = data || {};
+
+    // Require an ID.
+    if (!params.id) {
+      throw new ArgumentError('The id passed in params cannot be null or undefined');
+    }
+
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The hook Id has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.secrets.patch(params, data, cb);
+    }
+
+    return this.secrets.patch(params, data);
+  }
+
+  /**
+   * Remove secrets from a hook
+   *
+   * @example
+   * var params =  { id :'HOOK_ID'};
+   * var data =["DB_PASS"];
+   *
+   * management.hooks.removeSecrets(params, data, function (err, hook) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // secrets added.
+   * });
+   * @param   {object}    params      Hook parameters.
+   * @param   {string}    params.id   ID of the Hook.
+   * @param   {object}    data        Array of secret names
+   * @param   {Function}  [cb]        Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  removeSecrets(params, data, cb) {
+    params = params || {};
+    data = data || {};
+
+    // Require an ID.
+    if (!params.id) {
+      throw new ArgumentError('The id passed in params cannot be null or undefined');
+    }
+
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The hook Id has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.secrets.delete(params, data, cb);
+    }
+
+    return this.secrets.delete(params, data);
+  }
+}
+
+module.exports = HooksManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_JobsManager.js.html b/docs/management_JobsManager.js.html index 0b1a0388d..776834add 100644 --- a/docs/management_JobsManager.js.html +++ b/docs/management_JobsManager.js.html @@ -24,7 +24,8 @@
@@ -39,237 +40,328 @@

management/JobsManager.js

-
var request = require('request');
-var extend = require('util')._extend;
-var Promise = require('bluebird');
-var fs = require('fs');
+            
const axios = require('axios');
+const FormData = require('form-data');
+const fs = require('fs');
 
-var ArgumentError = require('rest-facade').ArgumentError;
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-/**
- * @class
  * Abstract the creation as well as the retrieval of async jobs.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var JobsManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide client options');
+class JobsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    this.options = options;
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Jobs Jobs endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.jobs = this._getRestClient('/jobs/:id');
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Jobs/:id/errors Errors endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.jobErrors = this._getRestClient('/jobs/:id/errors');
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Jobs/post_users_exports Create job to export users endpoint}
+     *
+     * @type {external:RestClient}
+     */
+    this.usersExports = this._getRestClient('/jobs/users-exports');
   }
 
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
-  }
+  /**
+   * Get a job by its ID.
+   *
+   * @example
+   * var params = {
+   *   id: '{JOB_ID}'
+   * };
+   *
+   * management.jobs.get(params, function (err, job) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Retrieved job.
+   *   console.log(job);
+   * });
+   * @param   {object}    params        Job parameters.
+   * @param   {string}    params.id     Job ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  get(params, cb) {
+    if (!params.id || typeof params.id !== 'string') {
+      throw new ArgumentError('The id parameter must be a valid job id');
+    }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+    if (cb && cb instanceof Function) {
+      return this.jobs.get(params, cb);
+    }
+
+    // Return a promise.
+    return this.jobs.get(params);
   }
 
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  _importUsers(data, cb) {
+    const { options } = this;
+    const url = `${options.baseUrl}/jobs/users-imports`;
+    const userData = data.users_json
+      ? Buffer.from(data.users_json)
+      : fs.createReadStream(data.users);
+    const userFilename = data.users_json ? 'users.json' : data.users;
+
+    const form = new FormData();
+    form.append('users', userData, userFilename);
+    form.append('connection_id', data.connection_id);
+    form.append('upsert', data.upsert === true ? 'true' : 'false');
+    form.append('send_completion_email', data.send_completion_email === false ? 'false' : 'true');
+
+    const headers = { ...options.headers, ...form.getHeaders() };
+    headers['Content-Type'] = 'multipart/form-data';
+
+    const promise = options.tokenProvider.getAccessToken().then(async (access_token) => {
+      try {
+        return await axios.post(url, form, {
+          headers: { ...headers, Authorization: `Bearer ${access_token}` },
+        });
+      } catch (err) {
+        if (!err.response) {
+          throw err;
+        }
 
-  this.options = options;
+        const res = err.response;
+        // `superagent` uses the error parameter in callback on http errors.
+        // the following code is intended to keep that behaviour (https://github.com/visionmedia/superagent/blob/master/lib/node/response.js#L170)
+        const error = new Error(`${'cannot POST' + ' '}${url} (${res.status})`);
+        error.status = res.status;
+        error.method = 'POST';
+        error.text = res.data.message || res.statusText || error.message;
+        throw error;
+      }
+    });
 
-  /**
-   * Provides an abstraction layer for consuming the
-   * {@link https://auth0.com/docs/api/v2#!/Jobs Jobs endpoint}.
-   *
-   * @type {external:RestClient}
-   */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/jobs/:id',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.jobs = new RetryRestClient(auth0RestClient, options.retry);
-};
+    // Don't return a promise if a callback was given.
+    if (cb && cb instanceof Function) {
+      promise.then(cb.bind(null, null)).catch(cb);
 
-/**
- * Get a job by its ID.
- *
- * @method   get
- * @memberOf module:management.JobsManager.prototype
- *
- * @example
- * var params = {
- *   id: '{JOB_ID}'
- * };
- *
- * management.jobs.get(params, function (err, job) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Retrieved job.
- *   console.log(job);
- * });
- *
- * @param   {Object}    params        Job parameters.
- * @param   {String}    params.id     Job ID.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return  {Promise|undefined}
- */
-JobsManager.prototype.get = function(params, cb) {
-  if (!params.id || typeof params.id !== 'string') {
-    throw new ArgumentError('The id parameter must be a valid job id');
+      return;
+    }
+
+    return promise;
   }
 
-  if (cb && cb instanceof Function) {
-    return this.jobs.get(params, cb);
+  /**
+   * Given a path to a file and a connection id, create a new job that imports the
+   * users contained in the file or JSON string and associate them with the given
+   * connection.
+   *
+   * @deprecated since version 2.26. It will be deleted in version 3.0.
+   * @example
+   * var params = {
+   *   connection_id: '{CONNECTION_ID}',
+   *   users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}'
+   * };
+   *
+   * management.jobs.importUsers(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    data                          Users import data.
+   * @param   {string}    data.connection_id            connection_id of the connection to which users will be imported.
+   * @param   {string}    [data.users]                  Path to the users data file. Either users or users_json is mandatory.
+   * @param   {string}    [data.users_json]             JSON data for the users.
+   * @param   {boolean}   [data.upsert]                 Whether to update users if they already exist (true) or to ignore them (false).
+   * @param   {boolean}   [data.send_completion_email]  Whether to send a completion email to all tenant owners when the job is finished (true) or not (false).
+   * @param   {Function}  [cb]                          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  importUsers(data, cb) {
+    console.warn(
+      '"importUsers" has been deprecated as it was inconsistent with the API. Please, use "importUsersJob" which returns the response data directly.'
+    );
+    return this._importUsers(data, cb);
   }
 
-  // Return a promise.
-  return this.jobs.get(params);
-};
+  /**
+   * Given a path to a file and a connection id, create a new job that imports the
+   * users contained in the file or JSON string and associate them with the given
+   * connection.
+   *
+   * @example
+   * var params = {
+   *   connection_id: '{CONNECTION_ID}',
+   *   users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}'
+   * };
+   *
+   * management.jobs.importUsers(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    data                          Users import data.
+   * @param   {string}    data.connection_id            connection_id of the connection to which users will be imported.
+   * @param   {string}    [data.users]                  Path to the users data file. Either users or users_json is mandatory.
+   * @param   {string}    [data.users_json]             JSON data for the users.
+   * @param   {boolean}   [data.upsert]                 Whether to update users if they already exist (true) or to ignore them (false).
+   * @param   {boolean}   [data.send_completion_email]  Whether to send a completion email to all tenant owners when the job is finished (true) or not (false).
+   * @param   {Function}  [cb]                          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  importUsersJob(data, cb) {
+    const promise = this._importUsers(data).then((response) => response.data);
 
-/**
- * Given a path to a file and a connection id, create a new job that imports the
- * users contained in the file or JSON string and associate them with the given
- * connection.
- *
- * @method   importUsers
- * @memberOf module:management.JobsManager.prototype
- *
- * @example
- * var params = {
- *   connection_id: '{CONNECTION_ID}',
- *   users: '{PATH_TO_USERS_FILE}',
- *   upsert: true, //optional
- *   send_completion_email: false //optional
- * };
- *
- * management.jobs.get(params, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- * });
- *
- * @param   {Object}    data                        Users import data.
- * @param   {String}    data.connectionId           Connection for the users insertion.
- * @param   {String}    data.users                  Path to the users data file.
- * @param   {String}    data.users_json             JSON data for the users.
- * @param   {String}    data.upsert                 OPTIONAL: set to true to upsert users, defaults to false
- * @param   {String}    data.send_completion_email  OPTIONAL: defaults to true
- * @param   {Function}  [cb]                        Callback function.
- *
- * @return  {Promise|undefined}
- */
-JobsManager.prototype.importUsers = function(data, cb) {
-  var options = this.options;
-  var headers = extend({}, options.headers);
-
-  headers['Content-Type'] = 'multipart/form-data';
-
-  var url = options.baseUrl + '/jobs/users-imports';
-  var method = 'POST';
-  var upsert = data.upsert === true ? 'true' : 'false';
-  var send_completion_email = data.send_completion_email === false ? 'false' : 'true';
-
-  var promise = options.tokenProvider.getAccessToken().then(function(access_token) {
-    return new Promise(function(resolve, reject) {
-      request(
-        {
-          url: url,
-          method: method,
-          headers: extend({ Authorization: `Bearer ${access_token}` }, headers),
-          formData: {
-            users: {
-              value: data.users_json
-                ? Buffer.from(data.users_json)
-                : fs.createReadStream(data.users),
-              options: {
-                filename: data.users_json ? 'users.json' : data.users
-              }
-            },
-            connection_id: data.connection_id,
-            upsert: upsert,
-            send_completion_email: send_completion_email
-          }
-        },
-        function(err, res) {
-          if (err) {
-            reject(err);
-            return;
-          }
-          // `superagent` uses the error parameter in callback on http errors.
-          // the following code is intended to keep that behaviour (https://github.com/visionmedia/superagent/blob/master/lib/node/response.js#L170)
-          var type = (res.statusCode / 100) | 0;
-          var isErrorResponse = 4 === type || 5 === type;
-          if (isErrorResponse) {
-            var error = new Error('cannot ' + method + ' ' + url + ' (' + res.statusCode + ')');
-            error.status = res.statusCode;
-            error.method = method;
-            error.text = res.text;
-            reject(error);
-          }
-          resolve(res);
-        }
-      );
-    });
-  });
+    // Don't return a promise if a callback was given.
+    if (cb && cb instanceof Function) {
+      promise.then(cb.bind(null, null)).catch(cb);
 
-  // Don't return a promise if a callback was given.
-  if (cb && cb instanceof Function) {
-    promise.then(cb.bind(null, null)).catch(cb);
+      return;
+    }
 
-    return;
+    return promise;
   }
 
-  return promise;
-};
+  /**
+   * Export all users to a file using a long running job.
+   *
+   * @example
+   * var data = {
+   *   connection_id: 'con_0000000000000001',
+   *   format: 'csv',
+   *   limit: 5,
+   *   fields: [
+   *     {
+   *       "name": "user_id"
+   *     },
+   *     {
+   *       "name": "name"
+   *     },
+   *     {
+   *       "name": "email"
+   *     },
+   *     {
+   *       "name": "identities[0].connection",
+   *       "export_as": "provider"
+   *     },
+   *     {
+   *       "name": "user_metadata.some_field"
+   *     }
+   *   ]
+   * }
+   *
+   * management.jobs.exportUsers(data, function (err, results) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Retrieved job.
+   *   console.log(results);
+   * });
+   * @param   {object}    data                  Users export data.
+   * @param   {string}    [data.connection_id]  The connection id of the connection from which users will be exported
+   * @param   {string}    [data.format]         The format of the file. Valid values are: "json" and "csv".
+   * @param   {number}    [data.limit]          Limit the number of records.
+   * @param   {object[]}  [data.fields]         A list of fields to be included in the CSV. If omitted, a set of predefined fields will be exported.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  exportUsers(data, cb) {
+    if (cb && cb instanceof Function) {
+      return this.usersExports.create(data, cb);
+    }
 
-/**
- * Send a verification email to a user.
- *
- * @method    verifyEmail
- * @memberOf module:management.JobsManager.prototype
- *
- * @example
- * var params = {
- * 	user_id: '{USER_ID}'
- * };
- *
- * management.jobs.verifyEmail(function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- * });
- *
- * @param   {Object}    data          User data object.
- * @param   {String}    data.user_id  ID of the user to be verified.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return  {Promise|undefined}
- */
-JobsManager.prototype.verifyEmail = function(data, cb) {
-  if (!data.user_id || typeof data.user_id !== 'string') {
-    throw new ArgumentError('Must specify a user ID');
+    return this.usersExports.create(data);
   }
 
-  if (cb && cb instanceof Function) {
-    return this.jobs.create({ id: 'verification-email' }, data, cb);
+  /**
+   * Given a job ID, retrieve the failed/errored items
+   *
+   * @example
+   * var params = {
+   *   id: '{JOB_ID}'
+   * };
+   *
+   * management.jobs.errors(params, function (err, job) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Retrieved job.
+   *   console.log(job);
+   * });
+   * @param   {object}    params        Job parameters.
+   * @param   {string}    params.id     Job ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  errors(params, cb) {
+    if (!params.id || typeof params.id !== 'string') {
+      throw new ArgumentError('The id parameter must be a valid job id');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.jobErrors.get(params, cb);
+    }
+
+    // Return a promise.
+    return this.jobErrors.get(params);
   }
 
-  // Return a promise.
-  return this.jobs.create({ id: 'verification-email' }, data);
-};
+  /**
+   * Send a verification email to a user.
+   *
+   * @example
+   * var params = {
+   * 	user_id: '{USER_ID}'
+   * };
+   *
+   * management.jobs.verifyEmail(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    data          User data object.
+   * @param   {string}    data.user_id  ID of the user to be verified.
+   * @param   {string}    [data.organization_id] Organization ID
+   * @param   {string}    [data.client_id] client_id of the client (application). If no value provided, the global Client ID will be used.
+   * @param   {object}    [data.identity] Used to verify secondary, federated, and passwordless-email identities.
+   * @param   {string}    data.identity.user_id user_id of the identity.
+   * @param   {string}    data.identity.provider provider of the identity.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  verifyEmail(data, cb) {
+    if (!data.user_id || typeof data.user_id !== 'string') {
+      throw new ArgumentError('Must specify a user ID');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.jobs.create({ id: 'verification-email' }, data, cb);
+    }
+
+    // Return a promise.
+    return this.jobs.create({ id: 'verification-email' }, data);
+  }
+}
 
 module.exports = JobsManager;
 
@@ -284,7 +376,7 @@

management/JobsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_LogStreamsManager.js.html b/docs/management_LogStreamsManager.js.html new file mode 100644 index 000000000..75c632cb1 --- /dev/null +++ b/docs/management_LogStreamsManager.js.html @@ -0,0 +1,197 @@ + + + + + + management/LogStreamsManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/LogStreamsManager.js

+ + + + + + + +
+
+
const BaseManager = require('./BaseManager');
+
+/**
+ * The logStreams class provides a simple abstraction for performing CRUD operations
+ * on Auth0 Log Streams.
+ */
+class LogStreamsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/management/v2#!/Log_Streams Auth0
+     *  Log Streams}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/log-streams/:id ');
+  }
+
+  /**
+   * Get all Log Streams.
+   *
+   * @example
+   *
+   * management.logStreams.getAll(function (err, logStreams) {
+   *   console.log(logStreams.length);
+   * });
+   * @param   {Function}  [cb]                    Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
+
+  /**
+   * Get an Auth0 Log Streams.
+   *
+   * @example
+   * management.logStreams.get({ id: LOG_STREAM_ID }, function (err, logStream) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(logStream);
+   * });
+   * @param   {object}    params          Log Stream parameters.
+   * @param   {string}    params.id       Log Stream ID.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
+   */
+  get(...args) {
+    return this.resource.get(...args);
+  }
+
+  /**
+   * Create an Auth0 Log Stream.
+   *
+   * @example
+   * management.logStreams.create(data, function (err, log) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(log);
+   * });
+   * @param   {object}    data          Log Stream data.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.resource.create(...args);
+  }
+
+  /**
+   * Update an Auth0 Log Streams.
+   *
+   * @example
+   * var data = { name: 'New name' };
+   * var params = { id: LOG_STREAM_ID };
+   *
+   * // Using auth0 instance.
+   * management.updateLogStream(params, data, function (err, logStream) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(logStream.name);  // 'New name'
+   * });
+   *
+   * // Using the logStreams manager directly.
+   * management.logStreams.update(params, data, function (err, logStream) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(logStream.name);
+   * });
+   * @param   {object}    params          Log Stream parameters.
+   * @param   {string}    params.id       Log Stream ID.
+   * @param   {object}    data            Updated Log Stream data.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
+   */
+  update(...args) {
+    return this.resource.patch(...args);
+  }
+
+  /**
+   * Delete an Auth0 Log Streams.
+   *
+   * @example
+   * management.logStreams.delete({ id: LOG_STREAM_ID }, function (err, log) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(log);
+   * });
+   * @param   {object}    params          Log Stream parameters.
+   * @param   {string}    params.id       Log Stream ID.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
+   */
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+}
+
+module.exports = LogStreamsManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_LogsManager.js.html b/docs/management_LogsManager.js.html index 6c9f5b9ea..61dc14542 100644 --- a/docs/management_LogsManager.js.html +++ b/docs/management_LogsManager.js.html @@ -24,7 +24,8 @@
@@ -39,118 +40,86 @@

management/LogsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * @class LogsManager
  * Represents the relationship between Auth0 and an Identity provider.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var LogsManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide client options');
-  }
-
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
-  }
-
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+class LogsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/v2#!/LogsManagers Auth0
+     *  Logs}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/logs/:id');
   }
 
   /**
-   * Options object for the Rest Client instance.
+   * Get all logs.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings and the search query. If pagination options are
+   *   not present, the first page of a limited number of results will be returned.
+   * </caption>
    *
-   * @type {Object}
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 2
+   * };
+   *
+   * management.logs.getAll(params, function (err, logs) {
+   *   console.log(logs.length);
+   * });
+   * @param   {object}    [params]                Logs params.
+   * @param   {string}    [params.q]              Search Criteria using Query String Syntax
+   * @param   {number}    [params.page]           Page number. Zero based
+   * @param   {number}    [params.per_page]       The amount of entries per page
+   * @param   {string}    [params.sort]           The field to use for sorting.
+   * @param   {string}    [params.fields]         A comma separated list of fields to include or exclude
+   * @param   {boolean}   [params.include_fields] true if the fields specified are to be included in the result, false otherwise.
+   * @param   {boolean}   [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false
+   * @param   {string}    [params.from]           For checkpoint pagination, log event Id from which to start selection from.
+   * @param   {number}    [params.take]           When using the `from` parameter, the number of entries to retrieve. Default 50, max 100.
+   * @param   {Function}  [cb]                    Callback function.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
 
   /**
-   * Provides an abstraction layer for performing CRUD operations on
-   * {@link https://auth0.com/docs/api/v2#!/LogsManagers Auth0
-   *  Logs}.
+   * Get an Auth0 log.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.logs.get({ id: EVENT_ID }, function (err, log) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(log);
+   * });
+   * @param   {object}    params          Log parameters.
+   * @param   {string}    params.id       Log ID.
+   * @param   {Function}  [cb]            Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/logs/:id ',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
-
-/**
- * Get all logs.
- *
- * @method    getAll
- * @memberOf  module:management.LogsManager.prototype
- *
- * @example <caption>
- *   This method takes an optional object as first argument that may be used to
- *   specify pagination settings and the search query. If pagination options are
- *   not present, the first page of a limited number of results will be returned.
- * </caption>
- *
- * // Pagination settings.
- * var params = {
- *   per_page: 10,
- *   page: 2
- * };
- *
- * management.logs.getAll(params, function (err, logs) {
- *   console.log(logs.length);
- * });
- *
- * @param   {Object}    [params]                Logs params.
- * @param   {String}    [params.q]              Search Criteria using Query String Syntax
- * @param   {Number}    [params.page]           Page number. Zero based
- * @param   {Number}    [params.per_page]       The amount of entries per page
- * @param   {String}    [params.sort]           The field to use for sorting.
- * @param   {String}    [params.fields]         A comma separated list of fields to include or exclude
- * @param   {Boolean}   [params.include_fields] true if the fields specified are to be included in the result, false otherwise.
- * @param   {Boolean}   [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false
- * @param   {Function}  [cb]                    Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(LogsManager, 'getAll', 'resource.getAll');
-
-/**
- * Get an Auth0 log.
- *
- * @method    get
- * @memberOf  module:management.LogsManager.prototype
- *
- * @example
- * management.logs.get({ id: EVENT_ID }, function (err, log) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(log);
- * });
- *
- * @param   {Object}    params          Log parameters.
- * @param   {String}    params.id       Log ID.
- * @param   {Function}  [cb]            Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(LogsManager, 'get', 'resource.get');
+  get(...args) {
+    return this.resource.get(...args);
+  }
+}
 
 module.exports = LogsManager;
 
@@ -165,7 +134,7 @@

management/LogsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_ManagementTokenProvider.js.html b/docs/management_ManagementTokenProvider.js.html index 2b5b18db8..5a21f62c9 100644 --- a/docs/management_ManagementTokenProvider.js.html +++ b/docs/management_ManagementTokenProvider.js.html @@ -24,7 +24,8 @@
@@ -39,142 +40,139 @@

management/ManagementTokenProvider.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var assign = Object.assign || require('object.assign');
-var AuthenticationClient = require('../auth');
-var memoizer = require('lru-memoizer');
-var Promise = require('bluebird');
-
-var DEFAULT_OPTIONS = { enableCache: true };
+            
const { ArgumentError } = require('rest-facade');
+const AuthenticationClient = require('../auth');
+const memoizer = require('lru-memoizer');
+const util = require('util');
 
 /**
- * @class ManagementTokenProvider
  * Auth0 Management API Token Provider.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object}  options                         Options for the ManagementTokenProvider.
- * @param {String}  options.domain                  ManagementClient server domain.
- * @param {String}  options.clientId                Non Interactive Client Id.
- * @param {String}  options.clientSecret            Non Interactive Client Secret.
- * @param {String}  options.scope                   Non Interactive Client Scope.
- * @param {String}  options.audience                Audience of the Management API.
- * @param {Boolean} [options.enableCache=true]      Enabled or Disable Cache
- * @param {Number}  [options.cacheTTLInSeconds]     By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden.
  */
-var ManagementTokenProvider = function(options) {
-  if (!options || typeof options !== 'object') {
-    throw new ArgumentError('Options must be an object');
-  }
+class ManagementTokenProvider {
+  /**
+   * @param {object}  options                         Options for the ManagementTokenProvider.
+   * @param {string}  options.domain                  ManagementClient server domain.
+   * @param {string}  options.clientId                Non Interactive Client Id.
+   * @param {string}  options.clientSecret            Non Interactive Client Secret.
+   * @param {string}  options.scope                   Non Interactive Client Scope.
+   * @param {string}  options.audience                Audience of the Management API.
+   * @param {boolean} [options.enableCache=true]      Enabled or Disable Cache
+   * @param {number}  [options.cacheTTLInSeconds]     By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden.
+   * @param {object}  [options.headers]               Additional headers that will be added to the outgoing requests.
+   */
+  constructor(options) {
+    if (!options || typeof options !== 'object') {
+      throw new ArgumentError('Options must be an object');
+    }
 
-  var params = assign({}, DEFAULT_OPTIONS, options);
+    const params = { enableCache: true, ...options };
 
-  if (!params.domain || params.domain.length === 0) {
-    throw new ArgumentError('Must provide a domain');
-  }
+    if (!params.domain || params.domain.length === 0) {
+      throw new ArgumentError('Must provide a domain');
+    }
 
-  if (!params.clientId || params.clientId.length === 0) {
-    throw new ArgumentError('Must provide a clientId');
-  }
+    if (!params.clientId || params.clientId.length === 0) {
+      throw new ArgumentError('Must provide a clientId');
+    }
 
-  if (!params.clientSecret || params.clientSecret.length === 0) {
-    throw new ArgumentError('Must provide a clientSecret');
-  }
+    if (!params.clientSecret || params.clientSecret.length === 0) {
+      throw new ArgumentError('Must provide a clientSecret');
+    }
 
-  if (!params.audience || params.audience.length === 0) {
-    throw new ArgumentError('Must provide a audience');
-  }
+    if (!params.audience || params.audience.length === 0) {
+      throw new ArgumentError('Must provide a audience');
+    }
 
-  if (typeof params.enableCache !== 'boolean') {
-    throw new ArgumentError('enableCache must be a boolean');
-  }
+    if (typeof params.enableCache !== 'boolean') {
+      throw new ArgumentError('enableCache must be a boolean');
+    }
 
-  if (params.enableCache && params.cacheTTLInSeconds) {
-    if (typeof params.cacheTTLInSeconds !== 'number') {
-      throw new ArgumentError('cacheTTLInSeconds must be a number');
+    if (params.enableCache && params.cacheTTLInSeconds) {
+      if (typeof params.cacheTTLInSeconds !== 'number') {
+        throw new ArgumentError('cacheTTLInSeconds must be a number');
+      }
+
+      if (params.cacheTTLInSeconds <= 0) {
+        throw new ArgumentError('cacheTTLInSeconds must be a greater than 0');
+      }
     }
 
-    if (params.cacheTTLInSeconds <= 0) {
-      throw new ArgumentError('cacheTTLInSeconds must be a greater than 0');
+    if (params.scope && typeof params.scope !== 'string') {
+      throw new ArgumentError('scope must be a string');
     }
-  }
 
-  if (params.scope && typeof params.scope !== 'string') {
-    throw new ArgumentError('scope must be a string');
+    this.options = params;
+    const authenticationClientOptions = {
+      domain: this.options.domain,
+      clientId: this.options.clientId,
+      clientSecret: this.options.clientSecret,
+      telemetry: this.options.telemetry,
+      clientInfo: this.options.clientInfo,
+      headers: this.options.headers,
+    };
+    this.authenticationClient = new AuthenticationClient(authenticationClientOptions);
+
+    const self = this;
+    this.getCachedAccessToken = util.promisify(
+      memoizer({
+        load(options, callback) {
+          self
+            .clientCredentialsGrant(options.domain, options.scope, options.audience)
+            .then((data) => {
+              callback(null, data);
+            })
+            .catch((err) => {
+              callback(err);
+            });
+        },
+        hash(options) {
+          return `${options.domain}-${options.clientId}-${options.scope}`;
+        },
+        itemMaxAge(options, data) {
+          if (options.cacheTTLInSeconds) {
+            return options.cacheTTLInSeconds * 1000;
+          }
+
+          // if the expires_in is lower or equal to than 10 seconds, do not subtract 10 additional seconds.
+          if (data.expires_in && data.expires_in <= 10 /* seconds */) {
+            return data.expires_in * 1000;
+          } else if (data.expires_in) {
+            // Subtract 10 seconds from expires_in to fetch a new one, before it expires.
+            return data.expires_in * 1000 - 10000 /* milliseconds */;
+          }
+          return 60 * 60 * 1000; //1h
+        },
+        max: 100,
+      })
+    );
   }
 
-  this.options = params;
-  var authenticationClientOptions = {
-    domain: this.options.domain,
-    clientId: this.options.clientId,
-    clientSecret: this.options.clientSecret,
-    telemetry: this.options.telemetry
-  };
-  this.authenticationClient = new AuthenticationClient(authenticationClientOptions);
-};
-
-/**
- * Returns the access_token.
- *
- * @method    getAccessToken
- * @memberOf  module:management.ManagementTokenProvider.prototype
- *
- * @return {Promise}   Promise returning an access_token.
- */
-ManagementTokenProvider.prototype.getAccessToken = function() {
-  if (this.options.enableCache) {
-    return this.getCachedAccessToken(this.options).then(function(data) {
+  /**
+   * Returns the access_token.
+   *
+   * @returns {Promise} Promise returning an access_token.
+   */
+  async getAccessToken() {
+    if (this.options.enableCache) {
+      const data = await this.getCachedAccessToken(this.options);
       return data.access_token;
-    });
-  } else {
-    return this.clientCredentialsGrant(
-      this.options.domain,
-      this.options.scope,
-      this.options.audience
-    ).then(function(data) {
+    } else {
+      const data = await this.clientCredentialsGrant(
+        this.options.domain,
+        this.options.scope,
+        this.options.audience
+      );
       return data.access_token;
-    });
+    }
   }
-};
-
-ManagementTokenProvider.prototype.getCachedAccessToken = Promise.promisify(
-  memoizer({
-    load: function(options, callback) {
-      this.clientCredentialsGrant(options.domain, options.scope, options.audience)
-        .then(function(data) {
-          callback(null, data);
-        })
-        .catch(function(err) {
-          callback(err);
-        });
-    },
-    hash: function(options) {
-      return options.domain + '-' + options.clientId + '-' + options.scope;
-    },
-    itemMaxAge: function(options, data) {
-      if (options.cacheTTLInSeconds) {
-        return options.cacheTTLInSeconds * 1000;
-      }
 
-      // if the expires_in is lower than 10 seconds, do not subtract 10 additional seconds.
-      if (data.expires_in && data.expires_in < 10 /* seconds */) {
-        return data.expires_in * 1000;
-      } else if (data.expires_in) {
-        // Subtract 10 seconds from expires_in to fetch a new one, before it expires.
-        return data.expires_in * 1000 - 10000 /* milliseconds */;
-      }
-      return 60 * 60 * 1000; //1h
-    },
-    max: 100
-  })
-);
-
-ManagementTokenProvider.prototype.clientCredentialsGrant = function(domain, scope, audience) {
-  return this.authenticationClient.clientCredentialsGrant({
-    audience: audience,
-    scope: scope
-  });
-};
+  clientCredentialsGrant(domain, scope, audience) {
+    return this.authenticationClient.clientCredentialsGrant({
+      audience,
+      scope,
+    });
+  }
+}
 
 module.exports = ManagementTokenProvider;
 
@@ -189,7 +187,7 @@

management/ManagementTokenProvider.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_MigrationsManager.js.html b/docs/management_MigrationsManager.js.html new file mode 100644 index 000000000..f5695cec3 --- /dev/null +++ b/docs/management_MigrationsManager.js.html @@ -0,0 +1,137 @@ + + + + + + management/MigrationsManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/MigrationsManager.js

+ + + + + + + +
+
+
const BaseManager = require('./BaseManager');
+
+/**
+ * Abstracts interaction with the migrations endpoint.
+ */
+class MigrationsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the migrations endpoint
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/migrations');
+  }
+
+  /**
+   * Update the tenant migrations.
+   *
+   * @example
+   * management.migrations.updateMigrations(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    data  The tenant migrations to be updated
+   * @param   {object}    data.flags  The tenant migrations flags to be updated
+   * @param   {Function}  [cb]  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  updateMigrations(data, cb) {
+    if (cb && cb instanceof Function) {
+      return this.resource.patch({}, data, cb);
+    }
+
+    // Return a promise.
+    return this.resource.patch({}, data);
+  }
+
+  /**
+   * Get the tenant migrations.
+   *
+   * @example
+   * management.migrations.getMigrations(function (err, migrations) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(migrations.flags);
+   * });
+   * @param data
+   * @param   {Function}  [cb]    Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getMigrations(data, cb) {
+    if (data instanceof Function && !cb) {
+      cb = data;
+      data = {};
+    }
+    if (cb && cb instanceof Function) {
+      return this.resource.get(data, cb);
+    }
+
+    // Return a promise.
+    return this.resource.get(data);
+  }
+}
+
+module.exports = MigrationsManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_OrganizationsManager.js.html b/docs/management_OrganizationsManager.js.html new file mode 100644 index 000000000..eb1103799 --- /dev/null +++ b/docs/management_OrganizationsManager.js.html @@ -0,0 +1,782 @@ + + + + + + management/OrganizationsManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/OrganizationsManager.js

+ + + + + + + +
+
+
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
+
+/**
+ * The organizations class provides a simple abstraction for performing CRUD operations
+ * on Auth0 OrganizationsManager.
+ */
+class OrganizationsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/v2}.
+     *
+     * @type {external:RestClient}
+     */
+    this.organizations = this._getRestClient('/organizations/:id');
+
+    this.connections = this._getRestClient('/organizations/:id/enabled_connections/:connection_id');
+
+    this.members = this._getRestClient('/organizations/:id/members/:user_id');
+
+    this.invitations = this._getRestClient('/organizations/:id/invitations/:invitation_id');
+
+    this.roles = this._getRestClient('/organizations/:id/members/:user_id/roles');
+
+    this.organizationsByName = this._getRestClient('/organizations/name/:name');
+  }
+
+  /**
+   * Create a new organization.
+   *
+   * @example
+   * management.organizations.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Organization created.
+   * });
+   * @param   {object}    data     Organization data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.organizations.create(...args);
+  }
+
+  /**
+   * Get all organizations.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   *
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   * management.organizations.getAll(params, function (err, organizations) {
+   *   console.log(organizations.length);
+   * });
+   * @param   {object}    [params]          Organizations parameters.
+   * @param   {number}    [params.per_page] Number of results per page.
+   * @param   {number}    [params.page]     Page number, zero indexed.
+   * @param   {string}    [params.from]     For checkpoint pagination, the Id from which to start selection from.
+   * @param   {number}    [params.take]     For checkpoint pagination, the number of entries to retrieve. Default 50.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.organizations.getAll(...args);
+  }
+
+  /**
+   * Get an Auth0 organization.
+   *
+   * @example
+   * management.organizations.getByID({ id: ORGANIZATION_ID }, function (err, role) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(organization);
+   * });
+   * @param   {object}    params        Organization parameters.
+   * @param   {string}    params.id     Organization ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getByID(...args) {
+    return this.organizations.get(...args);
+  }
+
+  /**
+   * Get an Auth0 organization.
+   *
+   * @example
+   * management.organizations.getByName({ name: ORGANIZATION_NAME}, function (err, role) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(organization);
+   * });
+   * @param   {object}    params        Organization parameters.
+   * @param   {string}    params.name   Organization name.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getByName(...args) {
+    return this.organizationsByName.get(...args);
+  }
+
+  /**
+   * Update an existing organization.
+   *
+   * @example
+   * var data = { display_name: 'New name' };
+   * var params = { id: ORGANIZATION_ID };
+   *
+   * management.organizations.update(params, data, function (err, organization) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(organization.name);  // 'New name'
+   * });
+   * @param   {object}    params        Organization parameters.
+   * @param   {string}    params.id     Organization ID.
+   * @param   {object}    data          Updated organization data.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  update(...args) {
+    return this.organizations.patch(...args);
+  }
+
+  /**
+   * Delete an existing organization.
+   *
+   * @example
+   * management.organizations.delete({ id: ORGANIZATION_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Organization deleted.
+   * });
+   * @param   {object}    params        Organization parameters.
+   * @param   {string}    params.id     Organization ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  delete(...args) {
+    return this.organizations.delete(...args);
+  }
+
+  /**
+   *Organization Connections
+   */
+
+  /**
+   * Get Enabled Connections in a Organization
+   *
+   * @example <caption>
+   *   This method takes an organization ID and returns the enabled connections in an Organization
+   * </caption>
+   * var params = {id : 'ORGANIZATION_ID'}
+   *
+   * management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID'}, function (err, enabled_connections) {
+   *   console.log(enabled_connections);
+   * });
+   * @param   {object}    params        Organization parameters.
+   * @param   {string}    params.id     Organization ID.
+   * @param   {Function}  [cb]                Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getEnabledConnections(params, callback) {
+    return this.connections.getAll(params, callback);
+  }
+
+  /**
+   * Get Enabled Connection in a Organization
+   *
+   * @example <caption>
+   *   This methods takes the organization ID and connection ID and returns the enabled connection
+   * </caption>
+   * var params = {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}
+   *
+   * management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}, function (err, enabled_connection) {
+   *   console.log(enabled_connection);
+   * });
+   * @param   {object}    params        Organization parameters.
+   * @param   {string}    params.id     Organization ID.
+   * @param   {string}    params.connection_id     Connection ID.
+   * @param   {Function}  [callback]                Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getEnabledConnection(params, callback) {
+    return this.connections.get(params, callback);
+  }
+
+  /**
+   * Add an enabled connection for an organization
+   *
+   * @example
+   * var params =  { id :'ORGANIZATION_ID'};
+   * var data = { "connection_id" : "CONNECTION_ID", assign_membership_on_login: false };
+   *
+   * management.organizations.addEnabledConnection(params, data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Organization parameters
+   * @param   {string}    params.id             ID of the Organization.
+   * @param   {object}    data                  enable connection data
+   * @param   {string}    data.connection_id    connection ID to enable
+   * @param   {boolean}   data.assign_membership_on_login flag to allow assign membership on login
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  addEnabledConnection(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.connections.create(params, data, cb);
+    }
+
+    return this.connections.create(params, data);
+  }
+
+  /**
+   * Remove an enabled connection from an organization
+   *
+   * @example
+   * var params =  { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
+   *
+   * management.organizations.removeEnabledConnection(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Organization parameters
+   * @param   {string}    params.id             ID of the Organization.
+   * @param   {string}    params.connection_id  ID of the Connection.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  removeEnabledConnection(params, cb) {
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (!params.connection_id) {
+      throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.connection_id !== 'string') {
+      throw new ArgumentError('The connection ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.connections.delete(params, {}, cb);
+    }
+
+    return this.connections.delete(params, {});
+  }
+
+  /**
+   * Update an enabled connection from an organization
+   *
+   * @example
+   * var params =  { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
+   * var data = { assign_membership_on_login: true };
+   *
+   * management.organizations.updateEnabledConnection(params, data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Organization parameters
+   * @param   {string}    params.id             ID of the Organization.
+   * @param   {string}    params.connection_id  ID of the Connection.
+   * @param   {object}    data                  Updated connection.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  updateEnabledConnection(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (!params.connection_id) {
+      throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.connection_id !== 'string') {
+      throw new ArgumentError('The connection ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.connections.patch(params, data, cb);
+    }
+
+    return this.connections.patch(params, data);
+  }
+
+  /**
+   *Organization Members
+   */
+
+  /**
+   * Get Members in a Organization
+   *
+   * @example <caption>
+   *   This method takes an organization ID and returns the members in an Organization
+   * </caption>
+   *
+   *  var params = {id : 'ORGANIZATION_ID'}
+   *
+   * management.organizations.getMembers( {id : 'ORGANIZATION_ID'}, function (err, members) {
+   *   console.log(members);
+   * });
+   * @param   {object}    params        Organization parameters
+   * @param   {string}    params.id     Organization ID
+   * @param   {string}    [params.from] For checkpoint pagination, the Id from which to start selection from.
+   * @param   {number}    [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getMembers(params, callback) {
+    return this.members.getAll(params, callback);
+  }
+
+  /**
+   * Add members in an organization
+   *
+   * @example
+   * var params =  { id :'ORGANIZATION_ID'};
+   * var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
+   * management.organizations.addMembers(params, data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Organization parameters
+   * @param   {string}    params.id             ID of the Organization.
+   * @param   {object}    data                  add members data
+   * @param   {Array}     data.members          Array of user IDs
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  addMembers(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.members.create(params, data, cb);
+    }
+
+    return this.members.create(params, data);
+  }
+
+  /**
+   * Remove members from an organization
+   *
+   * @example
+   * var params =  { id :'ORGANIZATION_ID' };
+   * var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
+   *
+   * management.organizations.removeMembers(params, data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Organization parameters
+   * @param   {string}    params.id             ID of the Organization.
+   * @param   {object}    data                  add members data
+   * @param   {Array}     data.members          Array of user IDs
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  removeMembers(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.members.delete(params, data, cb);
+    }
+
+    return this.members.delete(params, data);
+  }
+
+  /**
+   *Organization Invites
+   */
+
+  /**
+   * Get Invites in a Organization
+   *
+   * @example
+   * var params = {id : 'ORGANIZATION_ID'}
+   * @example <caption>
+   *   This method takes an organization ID and returns the invites in an Organization
+   * </caption>
+   *
+   * management.organizations.getInvitations( {id : 'ORGANIZATION_ID'}, function (err, invites) {
+   *   console.log(invites);
+   * @param callback
+   * });
+   * @param   {object}    params              Organization parameters
+   * @param   {string}    params.id           Organization ID
+   * @param   {number}    [params.per_page]   Number of results per page.
+   * @param   {number}    [params.page]       Page number, zero indexed.
+   * @param   {string}    [params.from]       For checkpoint pagination, the Id from which to start selection from.
+   * @param   {number}    [params.take]       For checkpoint pagination, the number of entries to retrieve. Default 50.
+   * @param   {string}    [params.fields]     Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.
+   * @param   {boolean}   [params.include_fields]     Whether specified fields are to be included (true) or excluded (false). Defaults to true.
+   * @param   {string}    [params.sort]      Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1.
+   * @param   {Function}  [cb]                Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getInvitations(params, callback) {
+    return this.invitations.getAll(params, callback);
+  }
+
+  /**
+   * Get an Invitation in a Organization
+   *
+   * @example
+   * var params = {id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}
+   * @param callback
+   * @example <caption>
+   *   This methods takes the organization ID and user ID and returns the invitation
+   * </caption>
+   *
+   * management.organizations.getInvitation({id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}, function (err, invite) {
+   *   console.log(invite);
+   * });
+   * @param   {object}    params                 Organization parameters
+   * @param   {string}    params.id              Organization ID
+   * @param   {string}    params.invitation_id   Invitation ID
+   * @param   {Function}  [cb]                   Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getInvitation(params, callback) {
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (!params.invitation_id) {
+      throw new ArgumentError('The invitation ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.invitation_id !== 'string') {
+      throw new ArgumentError('The invitation ID has to be a string');
+    }
+
+    return this.invitations.get(params, callback);
+  }
+
+  /**
+   * Create an invitation in an organization
+   *
+   * @example
+   * var params =  { id :'ORGANIZATION_ID'};
+   * var data = {
+   *   client_id: CLIENT_ID,
+   *   invitee: { email: 'invitee@example.com' },
+   *   inviter: { name: 'John Doe' }
+   * };
+   *
+   * management.organizations.createInvitation(params, data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}  params                        Organization parameters
+   * @param   {string}  params.id                     ID of the Organization.
+   * @param   {Array}   data                          Invitation data
+   * @param   {object}  data.inviter                  The person who is sending the invite.
+   * @param   {string}  data.inviter.name             Name of the person who is sending the invite
+   * @param   {object}  data.invitee                  Invitee to whom invitation is intended for
+   * @param   {object}  data.invitee.email            Email of the invitee to whom invitation is intended for
+   * @param   {string}  data.client_id                Auth0 client used to resolve the default application login URI. This endpoint must expect &invitation=... and &organization=... parameters (added by API2) to continue the flow with /authorize. If client_id  does not have configured login URI, use the tenant level default login route if configured, otherwise return 400
+   * @param   {string}  [data.connection_id]          Force user to authenticate against a specific identity provider.
+   * @param   {object}  [data.app_metadata]           Application metadata to be assigned to the user after accept the invitation.
+   * @param   {object}  [data.user_metadata]          User metadata to be assigned to the user after accept the invitation.
+   * @param   {Array}   [data.roles]                  List of roles to be assigned to the user
+   * @param   {number}  [data.ttl_sec]                Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days).  Upper limit on ttl_sec is 30 days.
+   * @param   {boolean} [data.send_invitation_email]  Whether the user will receive an invitation email (true) or no email (false). Default is true.
+   * @param   {Function}  [cb]                        Callback function.
+   * @returns  {Promise|undefined}
+   */
+  createInvitation(params, data, cb) {
+    data = data || [];
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.invitations.create(params, data, cb);
+    }
+
+    return this.invitations.create(params, data);
+  }
+
+  /**
+   * Delete an invitation from an organization
+   *
+   * @example
+   * var params =  { id :'ORGANIZATION_ID', invitation_id: 'INVITATION_ID };
+   *
+   * management.organizations.deleteInvitation(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Organization parameters
+   * @param   {string}    params.id             ID of the Organization.
+   * @param   {string}    params.invitation_id  Invitation ID
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  deleteInvitation(params, cb) {
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (!params.invitation_id) {
+      throw new ArgumentError('The invitation ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.invitation_id !== 'string') {
+      throw new ArgumentError('The invitation ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.invitations.delete(params, {}, cb);
+    }
+
+    return this.invitations.delete(params, {});
+  }
+
+  /**
+   *Organization Roles Membership
+   */
+
+  /**
+   * Get Roles from a Member in a Organization
+   *
+   * @example
+   * var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'}
+   * @param callback
+   * @example <caption>
+   *   This methods takes the organization ID and user ID and returns the roles
+   * </caption>
+   *
+   * management.organizations.getMemberRoles( {id : 'ORGANIZATION_ID', user_id: 'user_id'}, function (err, roles) {
+   *   console.log(roles);
+   * });
+   * @param   {object}    params              Organization parameters
+   * @param   {string}    params.id           ID of the Organization.
+   * @param   {string}    params.user_id      ID of the user.
+   * @param   {Function}  [cb]                Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getMemberRoles(params, callback) {
+    return this.roles.getAll(params, callback);
+  }
+
+  /**
+   * Add a Role to a Member in an organization
+   *
+   * @example
+   * var params =  {id : 'ORGANIZATION_ID', user_id: 'user_id'};
+   * var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
+   *
+   * management.organizations.addMemberRoles(params, data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Organization parameters
+   * @param   {string}    params.id             ID of the Organization.
+   * @param   {string}    params.user_id        ID of the user.
+   * @param   {object}    data                  Add member roles data.
+   * @param   {Array}     data.roles            Array of role IDs.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  addMemberRoles(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (!params.user_id) {
+      throw new ArgumentError('The user ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.user_id !== 'string') {
+      throw new ArgumentError('The user ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.roles.create(params, data, cb);
+    }
+
+    return this.roles.create(params, data);
+  }
+
+  /**
+   * Remove Roles from a Member of an organization
+   *
+   * @example
+   * var params =  { id :'ORGANIZATION_ID', user_id: 'USER_ID };
+   * var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
+   *
+   * management.organizations.removeMemberRoles(params, data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    params                Organization parameters
+   * @param   {string}    params.id             ID of the Organization.
+   * @param   {string}    params.user_id        Id of the User
+   * @param   {object}    data                  Remove member roles data.
+   * @param   {Array}     data.roles            Array of role IDs.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  removeMemberRoles(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    if (!params.id) {
+      throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The organization ID has to be a string');
+    }
+
+    if (!params.user_id) {
+      throw new ArgumentError('The user ID passed in params cannot be null or undefined');
+    }
+    if (typeof params.user_id !== 'string') {
+      throw new ArgumentError('The user ID has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.roles.delete(params, data, cb);
+    }
+
+    return this.roles.delete(params, data);
+  }
+}
+
+module.exports = OrganizationsManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_PromptsManager.js.html b/docs/management_PromptsManager.js.html new file mode 100644 index 000000000..f70d2f487 --- /dev/null +++ b/docs/management_PromptsManager.js.html @@ -0,0 +1,223 @@ + + + + + + management/PromptsManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/PromptsManager.js

+ + + + + + + +
+
+
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
+
+/**
+ * Manages settings related to prompts.
+ */
+class PromptsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/management/v2#!/Prompts Prompts endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/prompts');
+
+    /**
+     * Retrieve custom text for a specific prompt and language.
+     * {@link https://auth0.com/docs/api/management/v2#!/Prompts/get_custom_text_by_language Custom Text endpoint}
+     *
+     *
+     * @type {external:RestClient}
+     */
+    this.customTextByLanguage = this._getRestClient('/prompts/:prompt/custom-text/:language');
+  }
+
+  /**
+   * Update the prompts settings.
+   *
+   * @example
+   * management.prompts.updateSettings(params, data, function (err, prompts) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   * // Updated prompts
+   *    console.log(prompts);
+   * });
+   * @param   {object}    params            Prompts parameters.
+   * @param   {object}    data              Updated prompts data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  updateSettings(...args) {
+    return this.resource.patch(...args);
+  }
+
+  /**
+   * Get the prompts settings..
+   *
+   * @example
+   * management.prompts.getSettings(data, function (err, prompts) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   * // Prompts
+   *    console.log(prompts);
+   * });
+   * @param   {object}    params            Prompts parameters.
+   * @param   {object}    data              Prompts data.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns    {Promise|undefined}
+   */
+  getSettings(...args) {
+    return this.resource.get(...args);
+  }
+
+  /**
+   * Retrieve custom text for a specific prompt and language.
+   *
+   * @example
+   * var params = { prompt: PROMPT_NAME, language: LANGUAGE };
+   *
+   * management.prompts.getCustomTextByLanguage(params, function (err, customText) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log('CustomText', customText);
+   * });
+   * @param   {object}    params            Data object.
+   * @param   {string}    params.prompt     Name of the prompt.
+   * @param   {string}    params.language   Language to retrieve.
+   * @param   {Function}  [cb]              Callback function
+   * @returns  {Promise|undefined}
+   */
+  getCustomTextByLanguage(params, cb) {
+    params = params || {};
+
+    if (!params.prompt || typeof params.prompt !== 'string') {
+      throw new ArgumentError('The prompt parameter must be a string');
+    }
+
+    if (!params.language || typeof params.language !== 'string') {
+      throw new ArgumentError('The language parameter must be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.customTextByLanguage.get(params, cb);
+    }
+
+    return this.customTextByLanguage.get(params);
+  }
+
+  /**
+   * Set custom text for a specific prompt.
+   *
+   * @example
+   * var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT };
+   *
+   * management.prompts.updateCustomTextByLanguage(params, function (err, customText) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log('CustomText', customText);
+   * });
+   * @param   {object}    params            Data object.
+   * @param   {string}    params.prompt     Name of the prompt.
+   * @param   {string}    params.language   Language to retrieve.
+   * @param   {object}    params.body       An object containing custom dictionaries for a group of screens.
+   * @param   {Function}  [cb]              Callback function
+   * @returns  {Promise|undefined}
+   */
+  updateCustomTextByLanguage(params, cb) {
+    params = params || {};
+
+    if (!params.prompt || typeof params.prompt !== 'string') {
+      throw new ArgumentError('The prompt parameter must be a string');
+    }
+
+    if (!params.language || typeof params.language !== 'string') {
+      throw new ArgumentError('The language parameter must be a string');
+    }
+
+    if (!params.body || typeof params.body !== 'object') {
+      throw new ArgumentError('The body parameter must be an object');
+    }
+
+    const options = {
+      prompt: params.prompt,
+      language: params.language,
+    };
+
+    if (cb && cb instanceof Function) {
+      return this.customTextByLanguage.update(options, params.body, cb);
+    }
+
+    return this.customTextByLanguage.update(options, params.body);
+  }
+}
+
+module.exports = PromptsManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_ResourceServersManager.js.html b/docs/management_ResourceServersManager.js.html index 3cfaa5da4..26d6e3b52 100644 --- a/docs/management_ResourceServersManager.js.html +++ b/docs/management_ResourceServersManager.js.html @@ -24,7 +24,8 @@
@@ -39,13 +40,9 @@

management/ResourceServersManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * @class ResourceServersManager
  * Auth0 Resource Servers Manager.
  *
  * {@link https://auth0.com/docs/api/management/v2#!/Resource_Servers Resource Servers} represents
@@ -53,177 +50,137 @@ 

management/ResourceServersManager.js

* You can learn more about this in the * {@link https://auth0.com/docs/api-auth API Authorization} section of the * documentation. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ - -var ResourceServersManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide resource server options'); +class ResourceServersManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/ResourceServers Auth0 Resource Servers endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/resource-servers/:id'); } - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Create an API (Resource Server). + * + * @example + * management.resourceServers.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Resource Server created. + * }); + * @param {object} data Resource Server data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Get all resource servers. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.resourceServers.getAll(params, function (err, resourceServers) { + * console.log(resourceServers.length); + * }); + * @param {object} [params] Resource Servers parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); } /** - * Options object for the Rest Client instance. + * Get a Resource Server. + * + * @example + * management.resourceServers.get({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) { + * if (err) { + * // Handle error. + * } * - * @type {Object} + * console.log(resourceServer); + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - headers: options.headers, - query: { repeatParams: false } - }; + get(...args) { + return this.resource.get(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/ResourceServers Auth0 Resource Servers endpoint}. + * Update an existing resource server. + * + * @example + * var data = { name: 'newResourceServerName' }; + * var params = { id: RESOURCE_SERVER_ID }; * - * @type {external:RestClient} + * management.resourceServers.update(params, data, function (err, resourceServer) { + * if (err) { + * // Handle error. + * } + * + * console.log(resourceServer.name); // 'newResourceServernName' + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {object} data Updated Resource Server data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/resource-servers/:id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Create an API (Resource Server). - * - * @method create - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * management.resourceServers.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Resource Server created. - * }); - * - * @param {Object} data Resource Server data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'create', 'resource.create'); - -/** - * Get all resource servers. - * - * @method getAll - * @memberOf module:management.ResourceServersManager.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.resourceServers.getAll(params, function (err, resourceServers) { - * console.log(resourceServers.length); - * }); - * - * @param {Object} [params] Resource Servers parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'getAll', 'resource.getAll'); - -/** - * Get a Resource Server. - * - * @method get - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * management.resourceServers.get({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) { - * if (err) { - * // Handle error. - * } - * - * console.log(resourceServer); - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'get', 'resource.get'); - -/** - * Update an existing resource server. - * - * @method update - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * var data = { name: 'newResourceServerName' }; - * var params = { id: RESOURCE_SERVER_ID }; - * - * management.resourceServers.update(params, data, function (err, resourceServer) { - * if (err) { - * // Handle error. - * } - * - * console.log(resourceServer.name); // 'newResourceServernName' - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Object} data Updated Resource Server data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'update', 'resource.patch'); + update(...args) { + return this.resource.patch(...args); + } -/** - * Delete an existing Resource Server. - * - * @method delete - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * management.resourceServers.delete({ id: RESOURCE_SERVER_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Resource Server deleted. - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'delete', 'resource.delete'); + /** + * Delete an existing Resource Server. + * + * @example + * management.resourceServers.delete({ id: RESOURCE_SERVER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Resource Server deleted. + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } +} module.exports = ResourceServersManager;
@@ -238,7 +195,7 @@

management/ResourceServersManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_RolesManager.js.html b/docs/management_RolesManager.js.html new file mode 100644 index 000000000..54846cba5 --- /dev/null +++ b/docs/management_RolesManager.js.html @@ -0,0 +1,390 @@ + + + + + + management/RolesManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/RolesManager.js

+ + + + + + + +
+
+
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
+
+/**
+ * The role class provides a simple abstraction for performing CRUD operations
+ * on Auth0 RolesManager.
+ */
+class RolesManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/v2#!/RolesManager Auth0 RolesManagers}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/roles/:id');
+
+    this.permissions = this._getRestClient('/roles/:id/permissions');
+
+    this.users = this._getRestClient('/roles/:id/users');
+  }
+
+  /**
+   * Create a new role.
+   *
+   * @example
+   * management.roles.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Role created.
+   * });
+   * @param   {object}    data     Role data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.resource.create(...args);
+  }
+
+  /**
+   * Get all roles.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   *
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   * management.roles.getAll(params, function (err, roles) {
+   *   console.log(roles.length);
+   * });
+   * @param   {object}    [params]          Roles parameters.
+   * @param   {number}    [params.per_page] Number of results per page.
+   * @param   {number}    [params.page]     Page number, zero indexed.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
+
+  /**
+   * Get an Auth0 role.
+   *
+   * @example
+   * management.roles.get({ id: ROLE_ID }, function (err, role) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(role);
+   * });
+   * @param   {object}    params        Role parameters.
+   * @param   {string}    params.id     Role ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  get(...args) {
+    return this.resource.get(...args);
+  }
+
+  /**
+   * Update an existing role.
+   *
+   * @example
+   * var data = { name: 'New name' };
+   * var params = { id: ROLE_ID };
+   *
+   * // Using auth0 instance.
+   * management.updateRole(params, data, function (err, role) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(role.name);  // 'New name'
+   * });
+   *
+   * // Using the roles manager directly.
+   * management.roles.update(params, data, function (err, role) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(role.name);  // 'New name'
+   * });
+   * @param   {object}    params        Role parameters.
+   * @param   {string}    params.id     Role ID.
+   * @param   {object}    data          Updated role data.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  update(...args) {
+    return this.resource.patch(...args);
+  }
+
+  /**
+   * Delete an existing role.
+   *
+   * @example
+   * management.roles.delete({ id: ROLE_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Role deleted.
+   * });
+   * @param   {object}    params        Role parameters.
+   * @param   {string}    params.id     Role ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+
+  /**
+   * Get Permissions in a Role
+   *
+   * @param params
+   * @param callback
+   * @example
+   * var params = {id : 'ROLE_ID'}
+   * @example <caption>
+   *   This method takes a first argument as the roleId and returns the permissions within that role
+   * </caption>
+   *
+   * management.roles.getPermissions( {id : 'ROLE_ID'}, function (err, permissions) {
+   *   console.log(permissions);
+   * });
+   * @param   {string}    [email]           Email address of user(s) to find
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getPermissions(params, callback) {
+    return this.permissions.getAll(params, callback);
+  }
+
+  /**
+   * Add permissions in a role
+   *
+   * @example
+   * var params =  { id :'ROLE_ID'};
+   * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+   *
+   * management.roles.addPermissions(params, data, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // permissions added.
+   * });
+   * @param   {string}    params.id                ID of the Role.
+   * @param   {object}    data                permissions data
+   * @param   {string}    data.permissions    Array of permissions
+   * @param   {string}    data.permissions.permission_name  Name of a permission
+   * @param   {string}    data.permissions.resource_server_identifier  Identifier for a resource
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  addPermissions(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    // Require a user ID.
+    if (!params.id) {
+      throw new ArgumentError('The roleId passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The role Id has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.permissions.create(params, data, cb);
+    }
+
+    return this.permissions.create(params, data);
+  }
+
+  /**
+   * Remove permissions from a role
+   *
+   * @example
+   * var params =  { id :'ROLE_ID'};
+   * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+   *
+   * management.roles.removePermissions(params, data, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // permissions added.
+   * });
+   * @param   {string}    params.id                ID of the Role.
+   * @param   {object}    data                permissions data
+   * @param   {string}    data.permissions    Array of permissions
+   * @param   {string}    data.permissions.permission_name  Name of a permission
+   * @param   {string}    data.permissions.resource_server_identifier  Identifier for a resource
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  removePermissions(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    // Require a user ID.
+    if (!params.id) {
+      throw new ArgumentError('The roleId passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The role Id has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.permissions.delete(params, data, cb);
+    }
+
+    return this.permissions.delete(params, data);
+  }
+
+  /**
+   * Get Users in a Role
+   *
+   * @example
+   * var params = {
+   *   roleId: 'ROLE_ID',
+   *   per_page: 50,
+   *   page: 0
+   * };
+   * @example <caption>
+   *   This method takes a roleId and returns all users within that role. Supports offset (page, per_page) and checkpoint pagination (from, take). You must use checkpoint pagination to retrieve beyond the first 1000 records.
+   * </caption>
+   *
+   * management.roles.getUsers(params, function (err, users) {
+   *   console.log(users);
+   * });
+   * @param   {string}    [roleId]          Id of the role
+   * @param   {number}    [params.per_page] Number of results per page.
+   * @param   {number}    [params.page]     Page number, zero indexed.
+   * @param   {string}    [params.from]     For checkpoint pagination, the Id from which to start selection from.
+   * @param   {number}    [params.take]     For checkpoint pagination, the number of entries to retrieve. Default 50.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getUsers(params, callback) {
+    return this.users.getAll(params, callback);
+  }
+
+  /**
+   * Assign users to a role
+   *
+   * @example
+   * var params =  { id :'ROLE_ID'};
+   * var data = { "users" : ["userId1","userId2"]};
+   *
+   * management.roles.assignUsers(params, data, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // permissions added.
+   * });
+   * @param   {string}    params.id                ID of the Role.
+   * @param   {object}    data                permissions data
+   * @param   {string}    data.permissions    Array of permissions
+   * @param   {string}    data.permissions.permission_name  Name of a permission
+   * @param   {string}    data.permissions.resource_server_identifier  Identifier for a resource
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  assignUsers(params, data, cb) {
+    data = data || {};
+    params = params || {};
+
+    // Require a user ID.
+    if (!params.id) {
+      throw new ArgumentError('The roleId passed in params cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The role Id has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.users.create(params, data, cb);
+    }
+
+    return this.users.create(params, data);
+  }
+}
+
+module.exports = RolesManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_RulesConfigsManager.js.html b/docs/management_RulesConfigsManager.js.html index 18de21ac5..2672ed76f 100644 --- a/docs/management_RulesConfigsManager.js.html +++ b/docs/management_RulesConfigsManager.js.html @@ -24,7 +24,8 @@
@@ -39,135 +40,93 @@

management/RulesConfigsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-
-/**
- * @class RulesConfigsManager
  * The rules configs manager class provides a simple abstraction for performing CRUD operations
  * on Auth0 RulesConfigsManager.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var RulesConfigsManager = function (options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide manager options');
-  }
-
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
+class RulesConfigsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/v2#!/RulesConfigsManager Auth0 RulesConfigsManager}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/rules-configs/:key');
   }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+  /**
+   * Set a new rules config.
+   *
+   * @example
+   * var params = { key: RULE_CONFIG_KEY };
+   * var data =   { value: RULES_CONFIG_VALUE };
+   *
+   * management.rulesConfigs.set(params, data, function (err, rulesConfig) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Rules Config set.
+   * });
+   * @param   {object}    params        Rule Config parameters.
+   * @param   {string}    params.key    Rule Config key.
+   * @param   {object}    data          Rule Config Data parameters.
+   * @param   {string}    data.value    Rule Config Data value.
+   * @param   {Function}  [cb]    Callback function.
+   * @returns  {Promise|undefined}
+   */
+  set(...args) {
+    return this.resource.update(...args);
   }
 
   /**
-   * Options object for the Rest Client instance.
+   * Get all rules configs.
    *
-   * @type {Object}
+   * @example
+   * management.rulesConfigs.getAll(function (err, rulesConfig) {
+   *   console.log(rulesConfig.length);
+   * });
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  getAll(...args) {
+    return this.resource.getAll(...args);
+  }
 
   /**
-   * Provides an abstraction layer for performing CRUD operations on
-   * {@link https://auth0.com/docs/api/v2#!/RulesConfigsManager Auth0 RulesConfigsManager}.
+   * Delete an existing rules config.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.rulesConfigs.delete({ key: RULE_CONFIG_KEY }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Rules Config deleted.
+   * });
+   * @param   {object}    params        Rule Configs parameters.
+   * @param   {string}    params.key    Rule Configs key.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(options.baseUrl + '/rules-configs/:key', clientOptions, options.tokenProvider);
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
-
-
-/**
- * Set a new rules config.
- *
- * @method    set
- * @memberOf  module:management.RulesConfigsManager.prototype
- *
- * @example
- * var params = { key: RULE_CONFIG_KEY };
- * var data =   { value: RULES_CONFIG_VALUE };
- *  
- * management.rulesConfigs.set(params, data, function (err, rulesConfig) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Rules Config set.
- * });
- *
- * @param   {Object}    params        Rule Config parameters.
- * @param   {String}    params.key    Rule Config key.
- * @param   {Object}    data          Rule Config Data parameters.
- * @param   {String}    data.value    Rule Config Data value.
- * @param   {Function}  [cb]    Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(RulesConfigsManager, 'set', 'resource.update');
-
-
-/**
- * Get all rules configs.
- *
- * @method    getAll
- * @memberOf  module:management.RulesConfigsManager.prototype
- *
- * @example
- * management.rulesConfigs.getAll(function (err, rulesConfig) {
- *   console.log(rulesConfig.length);
- * });
- *
- * @param   {Function}  [cb]     Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(RulesConfigsManager, 'getAll', 'resource.getAll');
-
-
-/**
- * Delete an existing rules config.
- *
- * @method    delete
- * @memberOf  module:management.RulesConfigsManager.prototype
- *
- * @example
- * management.rulesConfigs.delete({ key: RULE_CONFIG_KEY }, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Rules Config deleted.
- * });
- *
- * @param   {Object}    params        Rule Configs parameters.
- * @param   {String}    params.key    Rule Configs key.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(RulesConfigsManager, 'delete', 'resource.delete');
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+}
 
-module.exports = RulesConfigsManager;
+module.exports = RulesConfigsManager; +
@@ -179,7 +138,7 @@

management/RulesConfigsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_RulesManager.js.html b/docs/management_RulesManager.js.html index 8f51c048f..69d1e9941 100644 --- a/docs/management_RulesManager.js.html +++ b/docs/management_RulesManager.js.html @@ -24,7 +24,8 @@
@@ -39,201 +40,152 @@

management/RulesManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var utils = require('../utils');
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-/**
- * @class RulesManager
  * The rule class provides a simple abstraction for performing CRUD operations
  * on Auth0 RulesManagers.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var RulesManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide manager options');
+class RulesManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for performing CRUD operations on
+     * {@link https://auth0.com/docs/api/v2#!/RulesManagers Auth0 RulesManagers}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/rules/:id');
   }
 
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
+  /**
+   * Create a new rule.
+   *
+   * @example
+   * management.rules.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Rule created.
+   * });
+   * @param   {object}    data     Rule data object.
+   * @param   {Function}  [cb]     Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(...args) {
+    return this.resource.create(...args);
   }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+  /**
+   * Get all rules.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings. If pagination options are not present,
+   *   the first page of a limited number of results will be returned.
+   * </caption>
+   *
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   * management.rules.getAll(params, function (err, rules) {
+   *   console.log(rules.length);
+   * });
+   * @param   {object}    [params]          Rules parameters.
+   * @param   {number}    [params.per_page] Number of results per page.
+   * @param   {number}    [params.page]     Page number, zero indexed.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.resource.getAll(...args);
   }
 
   /**
-   * Options object for the Rest Client instance.
+   * Get an Auth0 rule.
+   *
+   * @example
+   * management.rules.get({ id: RULE_ID }, function (err, rule) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
    *
-   * @type {Object}
+   *   console.log(rule);
+   * });
+   * @param   {object}    params        Rule parameters.
+   * @param   {string}    params.id     Rule ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
    */
-  var clientOptions = {
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  get(...args) {
+    return this.resource.get(...args);
+  }
 
   /**
-   * Provides an abstraction layer for performing CRUD operations on
-   * {@link https://auth0.com/docs/api/v2#!/RulesManagers Auth0 RulesManagers}.
+   * Update an existing rule.
+   *
+   * @example
+   * var data = { name: 'New name' };
+   * var params = { id: RULE_ID };
+   *
+   * // Using auth0 instance.
+   * management.updateRule(params, data, function (err, rule) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(rule.name);  // 'New name'
+   * });
+   *
+   * // Using the rules manager directly.
+   * management.rules.update(params, data, function (err, rule) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
    *
-   * @type {external:RestClient}
+   *   console.log(rule.name);  // 'New name'
+   * });
+   * @param   {object}    params        Rule parameters.
+   * @param   {string}    params.id     Rule ID.
+   * @param   {object}    data          Updated rule data.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/rules/:id',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.resource = new RetryRestClient(auth0RestClient, options.retry);
-};
-
-/**
- * Create a new rule.
- *
- * @method    create
- * @memberOf  module:management.RulesManager.prototype
- *
- * @example
- * management.rules.create(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Rule created.
- * });
- *
- * @param   {Object}    data     Rule data object.
- * @param   {Function}  [cb]     Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(RulesManager, 'create', 'resource.create');
-
-/**
- * Get all rules.
- *
- * @method    getAll
- * @memberOf  module:management.RulesManager.prototype
- *
- * @example <caption>
- *   This method takes an optional object as first argument that may be used to
- *   specify pagination settings. If pagination options are not present,
- *   the first page of a limited number of results will be returned.
- * </caption>
- *
- * // Pagination settings.
- * var params = {
- *   per_page: 10,
- *   page: 0
- * };
- *
- * management.rules.getAll(params, function (err, rules) {
- *   console.log(rules.length);
- * });
- *
- * @param   {Object}    [params]          Rules parameters.
- * @param   {Number}    [params.per_page] Number of results per page.
- * @param   {Number}    [params.page]     Page number, zero indexed.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(RulesManager, 'getAll', 'resource.getAll');
-
-/**
- * Get an Auth0 rule.
- *
- * @method    get
- * @memberOf  module:management.RulesManager.prototype
- *
- * @example
- * management.rules.get({ id: RULE_ID }, function (err, rule) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(rule);
- * });
- *
- * @param   {Object}    params        Rule parameters.
- * @param   {String}    params.id     Rule ID.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(RulesManager, 'get', 'resource.get');
-
-/**
- * Update an existing rule.
- *
- * @method    update
- * @memberOf  module:management.RulesManager.prototype
- *
- * @example
- * var data = { name: 'New name' };
- * var params = { id: RULE_ID };
- *
- * // Using auth0 instance.
- * management.updateRule(params, data, function (err, rule) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(rule.name);  // 'New name'
- * });
- *
- * // Using the rules manager directly.
- * management.rules.update(params, data, function (err, rule) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(rule.name);  // 'New name'
- * });
- *
- * @param   {Object}    params        Rule parameters.
- * @param   {String}    params.id     Rule ID.
- * @param   {Object}    data          Updated rule data.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(RulesManager, 'update', 'resource.patch');
+  update(...args) {
+    return this.resource.patch(...args);
+  }
 
-/**
- * Delete an existing rule.
- *
- * @method    delete
- * @memberOf  module:management.RulesManager.prototype
- *
- * @example
- * management.rules.delete({ id: RULE_ID }, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Rule deleted.
- * });
- *
- * @param   {Object}    params        Rule parameters.
- * @param   {String}    params.id     Rule ID.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return  {Promise|undefined}
- */
-utils.wrapPropertyMethod(RulesManager, 'delete', 'resource.delete');
+  /**
+   * Delete an existing rule.
+   *
+   * @example
+   * management.rules.delete({ id: RULE_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Rule deleted.
+   * });
+   * @param   {object}    params        Rule parameters.
+   * @param   {string}    params.id     Rule ID.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
+   */
+  delete(...args) {
+    return this.resource.delete(...args);
+  }
+}
 
 module.exports = RulesManager;
 
@@ -248,7 +200,7 @@

management/RulesManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_StatsManager.js.html b/docs/management_StatsManager.js.html index aff6e68c8..72f0e0c89 100644 --- a/docs/management_StatsManager.js.html +++ b/docs/management_StatsManager.js.html @@ -24,7 +24,8 @@
@@ -39,127 +40,88 @@

management/StatsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-/**
- * @class
  * Abstracts interaction with the stats endpoint.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var StatsManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide manager options');
-  }
-
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
-  }
-
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+class StatsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/stats/:type');
   }
 
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
-
   /**
-   * Provides an abstraction layer for consuming the
-   * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
+   * Get the daily stats.
+   *
+   * @example
+   * var params = {
+   *   from: '{YYYYMMDD}',  // First day included in the stats.
+   *   to: '{YYYYMMDD}'  // Last day included in the stats.
+   * };
    *
-   * @type {external:RestClient}
+   * management.stats.getDaily(params, function (err, stats) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(stats);
+   * });
+   * @param   {object}    params        Stats parameters.
+   * @param   {string}    params.from   The first day in YYYYMMDD format.
+   * @param   {string}    params.to     The last day in YYYYMMDD format.
+   * @param   {Function}  [cb]          Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/stats/:type',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.stats = new RetryRestClient(auth0RestClient, options.retry);
-};
+  getDaily(params, cb) {
+    params = params || {};
+    params.type = 'daily';
 
-/**
- * Get the daily stats.
- *
- * @method    getDaily
- * @memberOf  module:management.StatsManager.prototype
- *
- * @example
- * var params = {
- *   from: '{YYYYMMDD}',  // First day included in the stats.
- *   to: '{YYYYMMDD}'  // Last day included in the stats.
- * };
- *
- * management.stats.getDaily(params, function (err, stats) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(stats);
- * });
- *
- * @param   {Object}    params        Stats parameters.
- * @param   {String}    params.from   The first day in YYYYMMDD format.
- * @param   {String}    params.to     The last day in YYYYMMDD format.
- * @param   {Function}  [cb]          Callback function.
- *
- * @return  {Promise|undefined}
- */
-StatsManager.prototype.getDaily = function(params, cb) {
-  params = params || {};
-  params.type = 'daily';
+    if (cb && cb instanceof Function) {
+      return this.resource.get(params, cb);
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.stats.get(params, cb);
+    return this.resource.get(params);
   }
 
-  return this.stats.get(params);
-};
+  /**
+   * Get a the active users count.
+   *
+   * @example
+   * management.stats.getActiveUsersCount(function (err, usersCount) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(usersCount);
+   * });
+   * @param   {Function}  [cb]  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getActiveUsersCount(cb) {
+    const options = { type: 'active-users' };
 
-/**
- * Get a the active users count.
- *
- * @method    getActiveUsersCount
- * @memberOf  module:management.StatsManager.prototype
- *
- * @example
- * management.stats.getActiveUsersCount(function (err, usersCount) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(usersCount);
- * });
- *
- * @param   {Function}  [cb]  Callback function.
- *
- * @return  {Promise|undefined}
- */
-StatsManager.prototype.getActiveUsersCount = function(cb) {
-  var options = { type: 'active-users' };
+    if (cb && cb instanceof Function) {
+      return this.resource.get(options, cb);
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.stats.get(options, cb);
+    // Return a promise.
+    return this.resource.get(options);
   }
-
-  // Return a promise.
-  return this.stats.get(options);
-};
+}
 
 module.exports = StatsManager;
 
@@ -174,7 +136,7 @@

management/StatsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_TenantManager.js.html b/docs/management_TenantManager.js.html index 2a14fe60a..43ee95d0c 100644 --- a/docs/management_TenantManager.js.html +++ b/docs/management_TenantManager.js.html @@ -24,7 +24,8 @@
@@ -39,114 +40,80 @@

management/TenantManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
-
-/**
- * @class
  * Abstracts interaction with the tenant endpoint.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var TenantManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide manager options');
-  }
-
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
-  }
-
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+class TenantManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/tenants/settings');
   }
 
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
-
   /**
-   * Provides an abstraction layer for consuming the
-   * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
+   * Update the tenant settings.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.tenant.updateSettings(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}    data  The new tenant settings.
+   * @param   {Function}  [cb]  Callback function.
+   * @returns  {Promise|undefined}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/tenants/settings',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.tenant = new RetryRestClient(auth0RestClient, options.retry);
-};
+  updateSettings(data, cb) {
+    if (cb && cb instanceof Function) {
+      return this.resource.patch({}, data, cb);
+    }
 
-/**
- * Update the tenant settings.
- *
- * @method    updateSettings
- * @memberOf  module:management.TenantManager.prototype
- *
- * @example
- * management.tenant.updateSettings(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- * });
- *
- * @param   {Object}    data  The new tenant settings.
- * @param   {Function}  [cb]  Callback function.
- *
- * @return  {Promise|undefined}
- */
-TenantManager.prototype.updateSettings = function(data, cb) {
-  if (cb && cb instanceof Function) {
-    return this.tenant.patch({}, data, cb);
+    // Return a promise.
+    return this.resource.patch({}, data);
   }
 
-  // Return a promise.
-  return this.tenant.patch({}, data);
-};
-
-/**
- * Get the tenant settings..
- *
- * @method    getSettings
- * @memberOf  module:management.TenantManager.prototype
- *
- * @example
- * management.tenant.getSettings(function (err, settings) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(settings);
- * });
- *
- * @param   {Function}  [cb]  Callback function.
- *
- * @return  {Promise|undefined}
- */
-TenantManager.prototype.getSettings = function(cb) {
-  if (cb && cb instanceof Function) {
-    return this.tenant.get({}, cb);
+  /**
+   * Get the tenant settings..
+   *
+   * @example
+   * management.tenant.getSettings({ include_fields: true, fields: 'friendly_name' }, function (err, settings) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(settings);
+   * });
+   * @param   {object}    [data]  Request parameters
+   * @param   {Function}  [cb]    Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getSettings(data, cb) {
+    if (data instanceof Function && !cb) {
+      cb = data;
+      data = {};
+    }
+    if (cb && cb instanceof Function) {
+      return this.resource.get(data, cb);
+    }
+
+    // Return a promise.
+    return this.resource.get(data);
   }
-
-  // Return a promise.
-  return this.tenant.get({});
-};
+}
 
 module.exports = TenantManager;
 
@@ -161,7 +128,7 @@

management/TenantManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_TicketsManager.js.html b/docs/management_TicketsManager.js.html index ce0b83bb6..0449a4353 100644 --- a/docs/management_TicketsManager.js.html +++ b/docs/management_TicketsManager.js.html @@ -24,7 +24,8 @@
@@ -39,119 +40,108 @@

management/TicketsManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const BaseManager = require('./BaseManager');
 
 /**
- * @class
  * Abstracts interaction with the tickets endpoint.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var TicketsManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide manager options');
-  }
-
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
-  }
-
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+class TicketsManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Tickets Tickets endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.resource = this._getRestClient('/tickets/:type');
   }
 
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
-
   /**
-   * Provides an abstraction layer for consuming the
-   * {@link https://auth0.com/docs/api/v2#!/Tickets Tickets endpoint}.
+   * Create a new password change ticket.
    *
-   * @type {external:RestClient}
+   * @example
+   * var params = {
+   *   result_url: '{REDIRECT_URL}',  // Redirect after using the ticket.
+   *   user_id: '{USER_ID}',  // Optional.
+   *   email: '{USER_EMAIL}',  // Optional.
+   *   new_password: '{PASSWORD}'
+   * };
+   *
+   * management.tickets.changePassword(params, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}  data
+   * @param   {string}  [data.result_url] URL the user will be redirected to once ticket is used.
+   * @param   {string}  [data.user_id] user_id for whom the ticket should be created. (Conflicts with: connection_id, email)
+   * @param   {string}  [data.client_id] ID of the client.
+   * @param   {string}  [data.organization_id] ID of the organization.
+   * @param   {string}  [data.connection_id] ID of the connection.
+   * @param   {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration.
+   * @param   {string}  [data.email] Email of the user. (Requires: connection_id)
+   * @param   {boolean} [data.mark_email_as_verified] Whether to set the email_verified attribute to true (true) or whether it should not be updated (false).
+   * @param   {boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false).
+   * @param   {Function}  [cb]  Callback function.
+   * @returns  {Promise}
    */
-  var auth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/tickets/:type',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.ticket = new RetryRestClient(auth0RestClient, options.retry);
-};
+  changePassword(data, cb) {
+    const params = { type: 'password-change' };
 
-/**
- * Create a new password change ticket.
- *
- * @method    changePassword
- * @memberOf  module:management.TicketsManager.prototype
- *
- * @example
- * var params = {
- *   result_url: '{REDIRECT_URL}',  // Redirect after using the ticket.
- *   user_id: '{USER_ID}',  // Optional.
- *   email: '{USER_EMAIL}',  // Optional.
- *   new_password: '{PASSWORD}'
- * };
- *
- * management.tickets.changePassword(params, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- * });
- *
- * @param   {Function}  [cb]  Callback function.
- * @return  {Promise}
- */
-TicketsManager.prototype.changePassword = function(data, cb) {
-  var params = { type: 'password-change' };
+    if (cb && cb instanceof Function) {
+      return this.resource.create(params, data, cb);
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.ticket.create(params, data, cb);
+    // Return a promise.
+    return this.resource.create(params, data);
   }
 
-  // Return a promise.
-  return this.ticket.create(params, data);
-};
+  /**
+   * Create an email verification ticket.
+   *
+   * @example
+   * var data = {
+   *   user_id: '{USER_ID}',
+   *   result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
+   * };
+   *
+   * management.tickets.verifyEmail(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   * });
+   * @param   {object}  data
+   * @param   {string}  [data.result_url] URL the user will be redirected to once ticket is used.
+   * @param   {string}  data.user_id user_id for whom the ticket should be created.
+   * @param   {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration.
+   * @param   {boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the result_url (true), or not (false).
+   * @param   {object}  [data.identity] Used to verify secondary, federated, and passwordless-email identities.
+   * @param   {string}  data.identity.user_id user_id of the identity.
+   * @param   {string}  data.identity.provider provider of the identity.
+   * @param   {string}  [data.client_id] client ID.
+   * @param   {string}  [data.organization_id] organization ID.
+   * @param   {Function}  [cb]  Callback function.
+   * @returns  {Promise}
+   */
+  verifyEmail(data, cb) {
+    const params = { type: 'email-verification' };
 
-/**
- * Create an email verification ticket.
- *
- * @method    verifyEmail
- * @memberOf  module:management.TicketsManager.prototype
- *
- * @example
- * var data = {
- *   user_id: '{USER_ID}',
- *   result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
- * };
- *
- * management.tickets.verifyEmail(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- * });
- *
- * @param   {Function}  [cb]  Callback function.
- * @return  {Promise}
- */
-TicketsManager.prototype.verifyEmail = function(data, cb) {
-  var params = { type: 'email-verification' };
+    if (cb && cb instanceof Function) {
+      return this.resource.create(params, data, cb);
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.ticket.create(params, data, cb);
+    // Return a promise.
+    return this.resource.create(params, data);
   }
-
-  // Return a promise.
-  return this.ticket.create(params, data);
-};
+}
 
 module.exports = TicketsManager;
 
@@ -166,7 +156,7 @@

management/TicketsManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_UserBlocksManager.js.html b/docs/management_UserBlocksManager.js.html new file mode 100644 index 000000000..57bfd1477 --- /dev/null +++ b/docs/management_UserBlocksManager.js.html @@ -0,0 +1,182 @@ + + + + + + management/UserBlocksManager.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

management/UserBlocksManager.js

+ + + + + + + +
+
+
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
+
+/**
+ * Abstracts interaction with the user-blocks endpoint.
+ */
+class UserBlocksManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    this.userBlocksById = this._getRestClient('/user-blocks/:id');
+
+    this.userBlocksByIdentifier = this._getRestClient('/user-blocks');
+  }
+
+  /**
+   * Get user blocks by id.
+   *
+   * @example
+   * management.userBlocks.get({ id: USER_ID }, function (err, blocks) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(blocks);
+   * });
+   * @param   {object}    params      The user data object..
+   * @param   {string}    params.id   The user id.
+   * @param   {Function}  [cb]        Callback function
+   * @returns  {Promise|undefined}
+   */
+  get(params, ...restOfArgs) {
+    if (typeof params !== 'object' || typeof params.id !== 'string') {
+      throw new ArgumentError('You must provide an user id for the get method');
+    }
+
+    return this.userBlocksById.get(params, ...restOfArgs);
+  }
+
+  /**
+   * Unblock an user by its id.
+   *
+   * @example
+   * management.userBlocks.delete({ id: USER_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // User unblocked.
+   * });
+   * @param   {object}    params      The user data object..
+   * @param   {string}    params.id   The user id.
+   * @param   {Function}  [cb]        Callback function
+   * @returns  {Promise|undefined}
+   */
+  delete(params, ...restOfArgs) {
+    if (typeof params !== 'object' || typeof params.id !== 'string') {
+      throw new ArgumentError('You must provide an user id for the delete method');
+    }
+
+    return this.userBlocksById.delete(params, ...restOfArgs);
+  }
+
+  /**
+   * Get user blocks by identifier.
+   *
+   * @example
+   * management.userBlocks.getByIdentifier({ identifier: USER_ID }, function (err, blocks) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(blocks);
+   * });
+   * @param   {object}    params              The user data object..
+   * @param   {string}    params.identifier   The user identifier, any of: username, phone_number, email.
+   * @param   {Function}  [cb]                Callback function
+   * @returns  {Promise|undefined}
+   */
+  getByIdentifier(params, ...restOfArgs) {
+    if (typeof params !== 'object' || typeof params.identifier !== 'string') {
+      throw new ArgumentError('You must provide an user identifier for the getByIdentifier method');
+    }
+
+    return this.userBlocksByIdentifier.get(params, ...restOfArgs);
+  }
+
+  /**
+   * Unblock an user by identifier.
+   *
+   * @example
+   * management.userBlocks.deleteByIdentifier({ identifier: USER_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // User unblocked.
+   * });
+   * @param   {object}    params              The user data object..
+   * @param   {string}    params.identifier   The user identifier, any of: username, phone_number, email.
+   * @param   {Function}  [cb]                Callback function
+   * @returns  {Promise|undefined}
+   */
+  deleteByIdentifier(params, ...restOfArgs) {
+    if (typeof params !== 'object' || typeof params.identifier !== 'string') {
+      throw new ArgumentError(
+        'You must provide an user identifier for the deleteByIdentifier method'
+      );
+    }
+
+    return this.userBlocksByIdentifier.delete(params, ...restOfArgs);
+  }
+}
+
+module.exports = UserBlocksManager;
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme. +
+ + + + + diff --git a/docs/management_UsersManager.js.html b/docs/management_UsersManager.js.html index 76adaeaa4..4c46e5c56 100644 --- a/docs/management_UsersManager.js.html +++ b/docs/management_UsersManager.js.html @@ -24,7 +24,8 @@
@@ -39,630 +40,766 @@

management/UsersManager.js

-
var ArgumentError = require('rest-facade').ArgumentError;
-var Auth0RestClient = require('../Auth0RestClient');
-var RetryRestClient = require('../RetryRestClient');
+            
const { ArgumentError } = require('rest-facade');
+const BaseManager = require('./BaseManager');
 
-/**
- * Simple facade for consuming a REST API endpoint.
- * @external RestClient
- * @see https://github.com/ngonzalvez/rest-facade
- */
+const { sanitizeArguments } = require('../utils');
 
 /**
- * @class
  * Abstracts interaction with the users endpoint.
- * @constructor
- * @memberOf module:management
- *
- * @param {Object} options            The client options.
- * @param {String} options.baseUrl    The URL of the API.
- * @param {Object} [options.headers]  Headers to be included in all requests.
- * @param {Object} [options.retry]    Retry Policy Config
  */
-var UsersManager = function(options) {
-  if (options === null || typeof options !== 'object') {
-    throw new ArgumentError('Must provide manager options');
+class UsersManager extends BaseManager {
+  /**
+   * @param {object} options            The client options.
+   * @param {string} options.baseUrl    The URL of the API.
+   * @param {object} [options.headers]  Headers to be included in all requests.
+   * @param {object} [options.retry]    Retry Policy Config
+   */
+  constructor(options) {
+    super(options);
+
+    this.users = this._getRestClient('/users/:id');
+
+    /**
+     * Provides an abstraction layer for consuming the
+     * {@link https://auth0.com/docs/api/v2#!/Users/delete_multifactor_by_provider
+     * Multifactor Provider endpoint}.
+     *
+     * @type {external:RestClient}
+     */
+    this.multifactor = this._getRestClient('/users/:id/multifactor/:provider');
+
+    /**
+     * Provides a simple abstraction layer for linking user accounts.
+     *
+     * @type {external:RestClient}
+     */
+    this.identities = this._getRestClient('/users/:id/identities/:provider/:user_id');
+
+    /**
+     * Provides a simple abstraction layer for user logs
+     *
+     * @type {external:RestClient}
+     */
+    this.userLogs = this._getRestClient('/users/:id/logs');
+
+    /**
+     * Provides an abstraction layer for retrieving Guardian enrollments.
+     *
+     * @type {external:RestClient}
+     */
+    this.enrollments = this._getRestClient('/users/:id/enrollments');
+
+    /**
+     * Provides an abstraction layer for the new "users-by-email" API
+     *
+     * @type {external:RestClient}
+     */
+    this.usersByEmail = this._getRestClient('/users-by-email');
+
+    /**
+     * Provides an abstraction layer for regenerating Guardian recovery codes.
+     *
+     * @type {external:RestClient}
+     */
+    this.recoveryCodeRegenerations = this._getRestClient('/users/:id/recovery-code-regeneration');
+
+    /**
+     * Provides an abstraction layer for invalidating all remembered browsers for MFA.
+     *
+     * @type {external:RestClient}
+     */
+    this.invalidateRememberBrowsers = this._getRestClient(
+      '/users/:id/multifactor/actions/invalidate-remember-browser'
+    );
+
+    /**
+     * Provides an abstraction layer for CRD on roles for a user
+     *
+     * @type {external:RestClient}
+     */
+    this.roles = this._getRestClient('/users/:id/roles');
+
+    /**
+     * Provides an abstraction layer for CRD on permissions directly on a user
+     *
+     * @type {external:RestClient}
+     */
+    this.permissions = this._getRestClient('/users/:id/permissions');
+
+    this.organizations = this._getRestClient('/users/:id/organizations');
   }
 
-  if (options.baseUrl === null || options.baseUrl === undefined) {
-    throw new ArgumentError('Must provide a base URL for the API');
+  /**
+   * Create a new user.
+   *
+   * @example
+   * management.users.create(data, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // User created.
+   * });
+   * @param   {object}    data    User data.
+   * @param   {Function}  [cb]    Callback function.
+   * @returns  {Promise|undefined}
+   */
+  create(data, cb) {
+    if (cb && cb instanceof Function) {
+      return this.users.create(data, cb);
+    }
+
+    return this.users.create(data);
   }
 
-  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
-    throw new ArgumentError('The provided base URL is invalid');
+  /**
+   * Get all users.
+   *
+   * @example <caption>
+   *   This method takes an optional object as first argument that may be used to
+   *   specify pagination settings and the search query. If pagination options are
+   *   not present, the first page of a limited number of results will be returned.
+   * </caption>
+   *
+   * // Pagination settings.
+   * var params = {
+   *   per_page: 10,
+   *   page: 0
+   * };
+   *
+   * management.users.getAll(params, function (err, users) {
+   *   console.log(users.length);
+   * });
+   * @param   {object}    [params]          Users params.
+   * @param   {number}    [params.per_page] Number of results per page.
+   * @param   {number}    [params.page]     Page number, zero indexed.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getAll(...args) {
+    return this.users.getAll(...args);
   }
 
-  var clientOptions = {
-    errorFormatter: { message: 'message', name: 'error' },
-    headers: options.headers,
-    query: { repeatParams: false }
-  };
+  /**
+   * Get Users by an Email Address
+   *
+   * @example <caption>
+   *   This method takes a first argument as the Email address to look for
+   *   users, and uses the /users-by-email API, not the search API
+   * </caption>
+   *
+   * management.users.getByEmail('email@address', function (err, users) {
+   *   console.log(users);
+   * });
+   * @param   {string}    [email]                     Email address of user(s) to find
+   * @param   {object}    [options]                   Additional options to pass to the endpoint
+   * @param   {string}    [options.fields]            Comma-separated list of fields to include or exclude in the result
+   * @param   {boolean}   [options.include_fields]    Whether specified fields are to be included (true) or excluded (false). Defaults to true.
+   * @param   {Function}  [cb]                        Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getByEmail(email, options, cb) {
+    const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb);
 
-  var usersAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/users/:id',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.users = new RetryRestClient(usersAuth0RestClient, options.retry);
+    return this.usersByEmail.getAll({ email, ...sanitizedOptions }, sanitizedCb);
+  }
 
   /**
-   * Provides an abstraction layer for consuming the
-   * {@link https://auth0.com/docs/api/v2#!/Users/delete_multifactor_by_provider
-   * Multifactor Provider endpoint}.
+   * Get a user by its id.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.users.get({ id: USER_ID }, function (err, user) {
+   *   console.log(user);
+   * });
+   * @param   {object}    data      The user data object.
+   * @param   {string}    data.id   The user id.
+   * @param   {Function}  [cb]      Callback function.
+   * @returns  {Promise|undefined}
    */
-  var multifactorAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/users/:id/multifactor/:provider',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.multifactor = new RetryRestClient(multifactorAuth0RestClient, options.retry);
+  get(...args) {
+    return this.users.get(...args);
+  }
 
   /**
-   * Provides a simple abstraction layer for linking user accounts.
+   * Update a user by its id.
+   *
+   * @example
+   * var params = { id: USER_ID };
+   *
+   * management.users.update(params, data, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
    *
-   * @type {external:RestClient}
+   *   // Updated user.
+   *   console.log(user);
+   * });
+   * @param   {object}    params      The user parameters.
+   * @param   {string}    params.id   The user id.
+   * @param   {object}    data        New user data.
+   * @param   {Function}  [cb]        Callback function
+   * @returns  {Promise|undefined}
    */
-  var identitiesAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/users/:id/identities/:provider/:user_id',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.identities = new RetryRestClient(identitiesAuth0RestClient, options.retry);
+  update(...args) {
+    return this.users.patch(...args);
+  }
 
   /**
-   * Provides a simple abstraction layer for user logs
+   * Update the user metadata.
+   *
+   * @example
+   * var params = { id: USER_ID };
+   * var metadata = {
+   *   address: '123th Node.js Street'
+   * };
    *
-   * @type {external:RestClient}
+   * management.users.updateUserMetadata(params, metadata, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Updated user.
+   *   console.log(user);
+   * });
+   * @param   {object}    params      The user data object..
+   * @param   {string}    params.id   The user id.
+   * @param   {object}    metadata    New user metadata.
+   * @param   {Function}  [cb]        Callback function
+   * @returns  {Promise|undefined}
    */
-  var userLogsAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/users/:id/logs',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.userLogs = new RetryRestClient(userLogsAuth0RestClient, options.retry);
+  updateUserMetadata(params, metadata, cb) {
+    const data = {
+      user_metadata: metadata,
+    };
+
+    if (cb && cb instanceof Function) {
+      return this.users.patch(params, data, cb);
+    }
+
+    return this.users.patch(params, data);
+  }
 
   /**
-   * Provides an abstraction layer for retrieving Guardian enrollments.
+   * Update the app metadata.
    *
-   * @type {external:RestClient}
+   * @example
+   * var params = { id: USER_ID };
+   * var metadata = {
+   *   foo: 'bar'
+   * };
+   *
+   * management.users.updateAppMetadata(params, metadata, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Updated user.
+   *   console.log(user);
+   * });
+   * @param   {object}    params      The user data object..
+   * @param   {string}    params.id   The user id.
+   * @param   {object}    metadata    New app metadata.
+   * @param   {Function}  [cb]        Callback function
+   * @returns  {Promise|undefined}
    */
-  var enrollmentsAuth0RestClient = new Auth0RestClient(
-    options.baseUrl + '/users/:id/enrollments',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.enrollments = new RetryRestClient(enrollmentsAuth0RestClient, options.retry);
+  updateAppMetadata(params, metadata, cb) {
+    const data = {
+      app_metadata: metadata,
+    };
+
+    if (cb && cb instanceof Function) {
+      return this.users.patch(params, data, cb);
+    }
+
+    return this.users.patch(params, data);
+  }
 
   /**
-   * Provides an abstraction layer for the new "users-by-email" API
+   * Delete a user by its id.
    *
-   * @type {external:RestClient}
+   * @example
+   * management.users.delete({ id: USER_ID }, function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // User deleted.
+   * });
+   * @param   {object}    params      The user data object..
+   * @param   {string}    params.id   The user id.
+   * @param   {Function}  [cb]        Callback function
+   * @returns  {Promise|undefined}
    */
-  var usersByEmailClient = new Auth0RestClient(
-    options.baseUrl + '/users-by-email',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.usersByEmail = new RetryRestClient(usersByEmailClient, options.retry);
+  delete(params, ...restOfArgs) {
+    if (typeof params !== 'object' || typeof params.id !== 'string') {
+      throw new ArgumentError('You must provide an id for the delete method');
+    }
+
+    return this.users.delete(params, ...restOfArgs);
+  }
 
   /**
-   * Provides an abstraction layer for regenerating Guardian recovery codes.
+   * Delete all users.
+   *
+   * @example
+   * management.users.deleteAll(function (err) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
    *
-   * @type {external:RestClient}
+   *   // Users deleted
+   * });
+   * @param   {Function}  [cb]        Callback function
+   * @returns  {Promise|undefined}
+   * @deprecated This method will be removed in the next major release.
    */
-  var recoveryCodeRegenerationAuth0RestClients = new Auth0RestClient(
-    options.baseUrl + '/users/:id/recovery-code-regeneration',
-    clientOptions,
-    options.tokenProvider
-  );
-  this.recoveryCodeRegenerations = new RetryRestClient(
-    recoveryCodeRegenerationAuth0RestClients,
-    options.retry
-  );
-};
+  deleteAll(cb, ...restOfArgs) {
+    if (typeof cb !== 'function') {
+      const errorMsg = 'The deleteAll method only accepts a callback as argument';
 
-/**
- * Create a new user.
- *
- * @method    create
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * management.users.create(data, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // User created.
- * });
- *
- * @param   {Object}    data    User data.
- * @param   {Function}  [cb]    Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.create = function(data, cb) {
-  if (cb && cb instanceof Function) {
-    return this.users.create(data, cb);
-  }
+      throw new ArgumentError(errorMsg);
+    }
 
-  return this.users.create(data);
-};
+    return this.users.delete(cb, ...restOfArgs);
+  }
 
-/**
- * Get all users.
- *
- * @method    getAll
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example <caption>
- *   This method takes an optional object as first argument that may be used to
- *   specify pagination settings and the search query. If pagination options are
- *   not present, the first page of a limited number of results will be returned.
- * </caption>
- *
- * // Pagination settings.
- * var params = {
- *   per_page: 10,
- *   page: 0
- * };
- *
- * management.users.getAll(params, function (err, users) {
- *   console.log(users.length);
- * });
- *
- * @param   {Object}    [params]          Users params.
- * @param   {Number}    [params.per_page] Number of results per page.
- * @param   {Number}    [params.page]     Page number, zero indexed.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.getAll = function(params) {
-  return this.users.getAll.apply(this.users, arguments);
-};
+  /**
+   * Delete a multifactor provider.
+   *
+   * @example
+   * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
+   *
+   * management.users.deleteMultifactorProvider(params, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Users accounts unlinked.
+   * });
+   * @param   {object}    params            Data object.
+   * @param   {string}    params.id         The user id.
+   * @param   {string}    params.provider   Multifactor provider.
+   * @param   {Function}  [cb]              Callback function
+   * @returns  {Promise|undefined}
+   */
+  deleteMultifactorProvider(params, cb) {
+    params = params || {};
 
-/**
- * Get Users by an Email Address
- *
- * @method    getByEmail
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example <caption>
- *   This method takes a first argument as the Email address to look for
- *   users, and uses the /users-by-email API, not the search API
- * </caption>
- *
- * management.users.getByEmail('email@address', function (err, users) {
- *   console.log(users);
- * });
- *
- * @param   {String}    [email]           Email address of user(s) to find
- * @param   {Function}  [cb]              Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.getByEmail = function(email, callback) {
-  return this.usersByEmail.getAll({ email }, callback);
-};
+    if (!params.id || typeof params.id !== 'string') {
+      throw new ArgumentError('The id parameter must be a valid user id');
+    }
 
-/**
- * Get a user by its id.
- *
- * @method    get
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * management.users.get({ id: USER_ID }, function (err, user) {
- *   console.log(user);
- * });
- *
- * @param   {Object}    data      The user data object.
- * @param   {String}    data.id   The user id.
- * @param   {Function}  [cb]      Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.get = function() {
-  return this.users.get.apply(this.users, arguments);
-};
+    if (!params.provider || typeof params.provider !== 'string') {
+      throw new ArgumentError('Must specify a provider');
+    }
 
-/**
- * Update a user by its id.
- *
- * @method    update
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * var params = { id: USER_ID };
- *
- * management.users.update(params, data, function (err, user) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Updated user.
- *   console.log(user);
- * });
- *
- * @param   {Object}    params      The user parameters.
- * @param   {String}    params.id   The user id.
- * @param   {Object}    data        New user data.
- * @param   {Function}  [cb]        Callback function
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.update = function() {
-  return this.users.patch.apply(this.users, arguments);
-};
+    if (cb && cb instanceof Function) {
+      return this.multifactor.delete(params, cb);
+    }
 
-/**
- * Update the user metadata.
- *
- * @method    updateUserMetadata
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * var params = { id: USER_ID };
- * var metadata = {
- *   address: '123th Node.js Street'
- * };
- *
- * management.users.updateUserMetadata(params, metadata, function (err, user) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Updated user.
- *   console.log(user);
- * });
- *
- * @param   {Object}    params      The user data object..
- * @param   {String}    params.id   The user id.
- * @param   {Object}    metadata    New user metadata.
- * @param   {Function}  [cb]        Callback function
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.updateUserMetadata = function(params, metadata, cb) {
-  var data = {
-    user_metadata: metadata
-  };
+    return this.multifactor.delete(params);
+  }
 
-  if (cb && cb instanceof Function) {
-    return this.users.patch(params, data, cb);
+  /**
+   * Link the user with another account.
+   *
+   * @example
+   * var userId = 'USER_ID';
+   * var params = {
+   *   user_id: 'OTHER_USER_ID',
+   *   connection_id: 'CONNECTION_ID'
+   * };
+   *
+   * management.users.link(userId, params, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Users linked.
+   * });
+   * @param   {string}    userId                ID of the primary user.
+   * @param   {object}    params                Secondary user data.
+   * @param   {string}    params.user_id        ID of the user to be linked.
+   * @param   {string}    params.connection_id  ID of the connection to be used.
+   * @param   {string}    params.provider       Identity provider of the secondary user account being linked.
+   * @param   {string}    params.link_with      JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  link(userId, params, cb) {
+    const query = { id: userId };
+    params = params || {};
+
+    // Require a user ID.
+    if (!userId) {
+      throw new ArgumentError('The userId cannot be null or undefined');
+    }
+    if (typeof userId !== 'string') {
+      throw new ArgumentError('The userId has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.identities.create(query, params, cb);
+    }
+
+    return this.identities.create(query, params);
   }
 
-  return this.users.patch(params, data);
-};
+  /**
+   * Unlink the given accounts.
+   *
+   * @example
+   * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };
+   *
+   * management.users.unlink(params, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Users accounts unlinked.
+   * });
+   * @param   {object}    params            Linked users data.
+   * @param   {string}    params.id         Primary user ID.
+   * @param   {string}    params.provider   Identity provider in use.
+   * @param   {string}    params.user_id    Secondary user ID.
+   * @param   {Function}  [cb]              Callback function.
+   * @returns {Promise|undefined}
+   */
+  unlink(params, cb) {
+    params = params || {};
+
+    if (!params.id || typeof params.id !== 'string') {
+      throw new ArgumentError('id field is required');
+    }
 
-/**
- * Update the app metadata.
- *
- * @method    updateAppMetadata
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * var params = { id: USER_ID };
- * var metadata = {
- *   foo: 'bar'
- * };
- *
- * management.users.updateAppMetadata(params, metadata, function (err, user) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Updated user.
- *   console.log(user);
- * });
- *
- * @param   {Object}    params      The user data object..
- * @param   {String}    params.id   The user id.
- * @param   {Object}    metadata    New app metadata.
- * @param   {Function}  [cb]        Callback function
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.updateAppMetadata = function(params, metadata, cb) {
-  var data = {
-    app_metadata: metadata
-  };
+    if (!params.user_id || typeof params.user_id !== 'string') {
+      throw new ArgumentError('user_id field is required');
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.users.patch(params, data, cb);
-  }
+    if (!params.provider || typeof params.provider !== 'string') {
+      throw new ArgumentError('provider field is required');
+    }
 
-  return this.users.patch(params, data);
-};
+    if (cb && cb instanceof Function) {
+      return this.identities.delete(params, cb);
+    }
 
-/**
- * Delete a user by its id.
- *
- * @method    delete
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * management.users.delete({ id: USER_ID }, function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // User deleted.
- * });
- *
- *
- * @param   {Object}    params      The user data object..
- * @param   {String}    params.id   The user id.
- * @param   {Function}  [cb]        Callback function
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.delete = function(params) {
-  if (typeof params !== 'object' || typeof params.id !== 'string') {
-    throw new ArgumentError('You must provide an id for the delete method');
+    return this.identities.delete(params);
   }
 
-  return this.users.delete.apply(this.users, arguments);
-};
+  /**
+   * Get user's log events.
+   *
+   * @example
+   * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
+   *
+   * management.users.logs(params, function (err, logs) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   console.log(logs);
+   * });
+   * @param   {object}    params                Get logs data.
+   * @param   {string}    params.id             User id.
+   * @param   {number}    params.per_page       Number of results per page.
+   * @param   {number}    params.page           Page number, zero indexed.
+   * @param   {string}    params.sort           The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.
+   * @param   {boolean}   params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns {Promise|undefined}
+   */
+  logs(params, cb) {
+    params = params || {};
 
-/**
- * Delete all users.
- *
- * @method    deleteAll
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * management.users.deleteAll(function (err) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Users deleted
- * });
- *
- * @param   {Function}  [cb]        Callback function
- *
- * @return  {Promise|undefined}
- *
- * @deprecated This method will be removed in the next major release.
- */
-UsersManager.prototype.deleteAll = function(cb) {
-  if (typeof cb !== 'function') {
-    var errorMsg = 'The deleteAll method only accepts a callback as argument';
+    if (!params.id || typeof params.id !== 'string') {
+      throw new ArgumentError('id field is required');
+    }
+
+    return this.userLogs.get(params, cb);
+  }
 
-    throw new ArgumentError(errorMsg);
+  /**
+   * Get a list of Guardian enrollments.
+   *
+   * @example
+   * management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
+   *   console.log(enrollments);
+   * });
+   * @param   {object}    data      The user data object.
+   * @param   {string}    data.id   The user id.
+   * @param   {Function}  [cb]      Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getGuardianEnrollments(...args) {
+    return this.enrollments.get(...args);
   }
 
-  return this.users.delete.apply(this.users, arguments);
-};
+  /**
+   * Generate new Guardian recovery code.
+   *
+   * @example
+   * management.users.regenerateRecoveryCode("USER_ID", function (err, result) {
+   *   console.log(result.recovery_code);
+   * });
+   * @param   {object}    params                Get logs data.
+   * @param   {string}    params.id             User id.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  regenerateRecoveryCode(params, cb) {
+    if (!params || !params.id) {
+      throw new ArgumentError('The userId cannot be null or undefined');
+    }
 
-/**
- * Delete a multifactor provider.
- *
- * @method    deleteMultifactorProvider
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
- *
- * management.users.deleteMultifactorProvider(params, function (err, user) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Users accounts unlinked.
- * });
- *
- * @param   {Object}    params            Data object.
- * @param   {String}    params.id         The user id.
- * @param   {String}    params.provider   Multifactor provider.
- * @param   {Function}  [cb]              Callback function
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.deleteMultifactorProvider = function(params, cb) {
-  params = params || {};
+    if (cb && cb instanceof Function) {
+      return this.recoveryCodeRegenerations.create(params, {}, cb);
+    }
 
-  if (!params.id || typeof params.id !== 'string') {
-    throw new ArgumentError('The id parameter must be a valid user id');
+    return this.recoveryCodeRegenerations.create(params, {});
   }
 
-  if (!params.provider || typeof params.provider !== 'string') {
-    throw new ArgumentError('Must specify a provider');
+  /**
+   * Invalidate all remembered browsers for MFA.
+   *
+   * @example
+   * management.users.invalidateRememberBrowser({ id: USER_ID }, function (err, result) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // Invalidated all remembered browsers.
+   * });
+   * @param   {object}    params                The user data object.
+   * @param   {string}    params.id             The user id.
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+  invalidateRememberBrowser(params, cb) {
+    if (!params || !params.id) {
+      throw new ArgumentError('The userId cannot be null or undefined');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.invalidateRememberBrowsers.create(params, {}, cb);
+    }
+
+    return this.invalidateRememberBrowsers.create(params, {});
   }
 
-  if (cb && cb instanceof Function) {
-    return this.multifactor.delete(params, cb);
+  /**
+   * Get a list of roles for a user.
+   *
+   * @example
+   * management.users.getRoles({ id: USER_ID }, function (err, roles) {
+   *   console.log(roles);
+   * });
+   * @param   {object}    data      The user data object.
+   * @param   {string}    data.id   The user id.
+   * @param   {Function}  [cb]      Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getRoles(...args) {
+    return this.roles.getAll(...args);
   }
 
-  return this.multifactor.delete(params);
-};
+  /**
+   * Assign roles to a user
+   *
+   * @example
+   * var params =  { id : 'USER_ID';
+   * var data = { "roles" : ["roleId1", "roleID2"]};
+   *
+   * management.users.assignRoles(params, data, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // roles added.
+   * });
+   * @param   {object}    params       params object
+   * @param   {string}    params.id    user_id
+   * @param   {string}    data         data object containing list of role IDs
+   * @param   {string}    data.roles  Array of role IDs
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
+
+  assignRoles(params, data, cb) {
+    const query = params || {};
+    data = data || {};
 
-/**
- * Link the user with another account.
- *
- * @method    link
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * var userId = 'USER_ID';
- * var params = {
- *   user_id: 'OTHER_USER_ID',
- *   connection_id: 'CONNECTION_ID'
- * };
- *
- * management.users.link(userId, params, function (err, user) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Users linked.
- * });
- *
- * @param   {String}    userId                ID of the primary user.
- * @param   {Object}    params                Secondary user data.
- * @param   {String}    params.user_id        ID of the user to be linked.
- * @param   {String}    params.connection_id  ID of the connection to be used.
- * @param   {Function}  [cb]                  Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.link = function(userId, params, cb) {
-  var query = { id: userId };
-  params = params || {};
+    // Require a user ID.
+    if (!params.id) {
+      throw new ArgumentError('The user_id cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The user_id has to be a string');
+    }
 
-  // Require a user ID.
-  if (!userId) {
-    throw new ArgumentError('The userId cannot be null or undefined');
-  }
-  if (typeof userId !== 'string') {
-    throw new ArgumentError('The userId has to be a string');
-  }
+    if (cb && cb instanceof Function) {
+      return this.roles.create(query, data, cb);
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.identities.create(query, params, cb);
+    return this.roles.create(query, data);
   }
 
-  return this.identities.create(query, params);
-};
+  /**
+   * Remove roles from a user
+   *
+   * @example
+   * var params =  { id : 'USER_ID';
+   * var data = { "roles" : ["roleId1", "roleID2"]};
+   *
+   * management.users.removeRoles(params, data, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // roles removed.
+   * });
+   * @param   {object}    params       params object
+   * @param   {string}    params.id    user_id
+   * @param   {string}    data         data object containing list of role IDs
+   * @param   {string}    data.roles  Array of role IDs
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
 
-/**
- * Unlink the given accounts.
- *
- * @method    unlink
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };
- *
- * management.users.unlink(params, function (err, user) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   // Users accounts unlinked.
- * });
- *
- * @param   {Object}    params            Linked users data.
- * @param   {String}    params.id         Primary user ID.
- * @param   {String}    params.provider   Identity provider in use.
- * @param   {String}    params.user_id    Secondary user ID.
- * @param   {Function}  [cb]              Callback function.
- *
- * @return {Promise|undefined}
- */
-UsersManager.prototype.unlink = function(params, cb) {
-  params = params || {};
+  removeRoles(params, data, cb) {
+    const query = params || {};
+    data = data || {};
 
-  if (!params.id || typeof params.id !== 'string') {
-    throw new ArgumentError('id field is required');
-  }
+    // Require a user ID.
+    if (!params.id) {
+      throw new ArgumentError('The user_id cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The user_id has to be a string');
+    }
 
-  if (!params.user_id || typeof params.user_id !== 'string') {
-    throw new ArgumentError('user_id field is required');
-  }
+    if (cb && cb instanceof Function) {
+      return this.roles.delete(query, data, cb);
+    }
 
-  if (!params.provider || typeof params.provider !== 'string') {
-    throw new ArgumentError('provider field is required');
+    return this.roles.delete(query, data);
   }
 
-  if (cb && cb instanceof Function) {
-    return this.identities.delete(params, cb);
+  /**
+   * Get a list of permissions for a user.
+   *
+   * @example
+   * management.users.getPermissions({ id: USER_ID }, function (err, permissions) {
+   *   console.log(permissions);
+   * });
+   * @param   {object}    data      The user data object.
+   * @param   {string}    data.id   The user id.
+   * @param   {Function}  [cb]      Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getPermissions(...args) {
+    return this.permissions.getAll(...args);
   }
 
-  return this.identities.delete(params);
-};
+  /**
+   * Assign permissions to a user
+   *
+   * @example
+   * var params =  { id : 'USER_ID';
+   * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+   *
+   * management.users.assignPermissions(params, data, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // permissions added.
+   * });
+   * @param   {object}    params       params object
+   * @param   {string}    params.id    user_id
+   * @param   {string}    data         data object containing list of permissions
+   * @param   {string}    data.permissions  Array of permission IDs
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
 
-/**
- * Get user's log events.
- *
- * @method    logs
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
- *
- * management.users.logs(params, function (err, logs) {
- *   if (err) {
- *     // Handle error.
- *   }
- *
- *   console.log(logs);
- * });
- *
- * @param   {Object}    params                Get logs data.
- * @param   {String}    params.id             User id.
- * @param   {Number}    params.per_page       Number of results per page.
- * @param   {Number}    params.page           Page number, zero indexed.
- * @param   {String}    params.sort           The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.
- * @param   {Boolean}   params.include_totals true if a query summary must be included in the result, false otherwise. Default false;
- * @param   {Function}  [cb]                  Callback function.
- *
- * @return {Promise|undefined}
- */
-UsersManager.prototype.logs = function(params, cb) {
-  params = params || {};
+  assignPermissions(params, data, cb) {
+    const query = params || {};
+    data = data || {};
+
+    // Require a user ID.
+    if (!params.id) {
+      throw new ArgumentError('The user_id cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The user_id has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.permissions.create(query, data, cb);
+    }
 
-  if (!params.id || typeof params.id !== 'string') {
-    throw new ArgumentError('id field is required');
+    return this.permissions.create(query, data);
   }
 
-  return this.userLogs.get(params, cb);
-};
+  /**
+   * Remove permissions from a user
+   *
+   * @example
+   * var params =  { id : 'USER_ID';
+   * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};
+   *
+   * management.users.removePermissions(params, data, function (err, user) {
+   *   if (err) {
+   *     // Handle error.
+   *   }
+   *
+   *   // permissions removed.
+   * });
+   * @param   {object}    params       params object
+   * @param   {string}    params.id    user_id
+   * @param   {object}    data         data object containing list of permission IDs
+   * @param   {string}    data.permissions  Array of permission IDs
+   * @param   {Function}  [cb]                  Callback function.
+   * @returns  {Promise|undefined}
+   */
 
-/**
- * Get a list of Guardian enrollments.
- *
- * @method    getGuardianEnrollments
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
- *   console.log(enrollments);
- * });
- *
- * @param   {Object}    data      The user data object.
- * @param   {String}    data.id   The user id.
- * @param   {Function}  [cb]      Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.getGuardianEnrollments = function() {
-  return this.enrollments.get.apply(this.enrollments, arguments);
-};
+  removePermissions(params, data, cb) {
+    const query = params || {};
+    data = data || {};
 
-/**
- * Generate new Guardian recovery code.
- *
- * @method    regenerateRecoveryCode
- * @memberOf  module:management.UsersManager.prototype
- *
- * @example
- * management.users.regenerateRecoveryCode("USER_ID", function (err, result) {
- *   console.log(result.recovery_code);
- * });
- *
- * @param   {Object}    params                Get logs data.
- * @param   {String}    params.id             User id.
- * @param   {Function}  [cb]                  Callback function.
- *
- * @return  {Promise|undefined}
- */
-UsersManager.prototype.regenerateRecoveryCode = function(params, cb) {
-  if (!params || !params.id) {
-    throw new ArgumentError('The userId cannot be null or undefined');
-  }
+    // Require a user ID.
+    if (!params.id) {
+      throw new ArgumentError('The user_id cannot be null or undefined');
+    }
+    if (typeof params.id !== 'string') {
+      throw new ArgumentError('The user_id has to be a string');
+    }
+
+    if (cb && cb instanceof Function) {
+      return this.permissions.delete(query, data, cb);
+    }
 
-  if (cb && cb instanceof Function) {
-    return this.recoveryCodeRegenerations.create(params, {}, cb);
+    return this.permissions.delete(query, data);
   }
 
-  return this.recoveryCodeRegenerations.create(params, {});
-};
+  /**
+   * Get a list of organizations for a user.
+   *
+   * @example
+   * management.users.getUserOrganizations({ id: USER_ID }, function (err, orgs) {
+   *   console.log(orgs);
+   * });
+   * @param   {object}    data      The user data object.
+   * @param   {string}    data.id   The user id.
+   * @param   {Function}  [cb]      Callback function.
+   * @returns  {Promise|undefined}
+   */
+  getUserOrganizations(...args) {
+    return this.organizations.getAll(...args);
+  }
+}
 
 module.exports = UsersManager;
 
@@ -677,7 +814,7 @@

management/UsersManager.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/management_index.js.html b/docs/management_index.js.html index 9e4daa584..137d5d0a4 100644 --- a/docs/management_index.js.html +++ b/docs/management_index.js.html @@ -24,7 +24,8 @@
@@ -39,50 +40,53 @@

management/index.js

-
/** @module management */
-
-var util = require('util');
-
-var pkg = require('../../package.json');
-var utils = require('../utils');
-var jsonToBase64 = utils.jsonToBase64;
-var ArgumentError = require('rest-facade').ArgumentError;
-var assign = Object.assign || require('object.assign');
+            
const util = require('util');
+const utils = require('../utils');
+const { jsonToBase64, generateClientInfo } = utils;
+const { ArgumentError } = require('rest-facade');
 
 // Managers.
-var ClientsManager = require('./ClientsManager');
-var ClientGrantsManager = require('./ClientGrantsManager');
-var UsersManager = require('./UsersManager');
-var ConnectionsManager = require('./ConnectionsManager');
-var BlacklistedTokensManager = require('./BlacklistedTokensManager');
-var RulesManager = require('./RulesManager');
-var DeviceCredentialsManager = require('./DeviceCredentialsManager');
-var EmailProviderManager = require('./EmailProviderManager');
-var StatsManager = require('./StatsManager');
-var TenantManager = require('./TenantManager');
-var JobsManager = require('./JobsManager');
-var TicketsManager = require('./TicketsManager');
-var LogsManager = require('./LogsManager');
-var ResourceServersManager = require('./ResourceServersManager');
-var ManagementTokenProvider = require('./ManagementTokenProvider');
-var RulesConfigsManager = require('./RulesConfigsManager');
-var EmailTemplatesManager = require('./EmailTemplatesManager');
-var GuardianManager = require('./GuardianManager');
-var CustomDomainsManager = require('./CustomDomainsManager');
-
-var BASE_URL_FORMAT = 'https://%s/api/v2';
-var MANAGEMENT_API_AUD_FORMAT = 'https://%s/api/v2/';
+const ClientsManager = require('./ClientsManager');
+const ClientGrantsManager = require('./ClientGrantsManager');
+const GrantsManager = require('./GrantsManager');
+const UsersManager = require('./UsersManager');
+const UserBlocksManager = require('./UserBlocksManager');
+const ConnectionsManager = require('./ConnectionsManager');
+const AttackProtectionManager = require('./AttackProtectionManager');
+const BlacklistedTokensManager = require('./BlacklistedTokensManager');
+const RulesManager = require('./RulesManager');
+const DeviceCredentialsManager = require('./DeviceCredentialsManager');
+const EmailProviderManager = require('./EmailProviderManager');
+const StatsManager = require('./StatsManager');
+const TenantManager = require('./TenantManager');
+const JobsManager = require('./JobsManager');
+const TicketsManager = require('./TicketsManager');
+const LogsManager = require('./LogsManager');
+const LogStreamsManager = require('./LogStreamsManager');
+const ResourceServersManager = require('./ResourceServersManager');
+const ManagementTokenProvider = require('./ManagementTokenProvider');
+const RulesConfigsManager = require('./RulesConfigsManager');
+const EmailTemplatesManager = require('./EmailTemplatesManager');
+const GuardianManager = require('./GuardianManager');
+const CustomDomainsManager = require('./CustomDomainsManager');
+const RolesManager = require('./RolesManager');
+const HooksManager = require('./HooksManager');
+const BrandingManager = require('./BrandingManager');
+const MigrationsManager = require('./MigrationsManager');
+const PromptsManager = require('./PromptsManager');
+const ActionsManager = require('./ActionsManager');
+const OrganizationsManager = require('./OrganizationsManager');
+
+const BASE_URL_FORMAT = 'https://%s/api/v2';
+const MANAGEMENT_API_AUD_FORMAT = 'https://%s/api/v2/';
 
 /**
- * @class ManagementClient
  * Management API SDK.
  *
  * The Auth0 Management API is meant to be used by back-end servers or trusted
  * parties performing administrative tasks. Generally speaking, anything that
  * can be done through the Auth0 dashboard (and more) can also be done through
  * this API.
- * @constructor
- * @memberOf module:management
  *
  * @example <caption>
  *   Initialize your client class with an API v2 token (you can generate one
@@ -94,8 +98,6 @@ 

management/index.js

* domain: '{YOUR_ACCOUNT}.auth0.com', * token: '{YOUR_API_V2_TOKEN}' * }); - * - * * @example <caption> * Initialize your client class, by using a Non Interactive Client to fetch an access_token * via the Client Credentials Grant. @@ -113,2127 +115,3309 @@

management/index.js

* cacheTTLInSeconds: 10 * } * }); - * - * @param {Object} options Options for the ManagementClient SDK. - * If a token is provided only the domain is required, other parameters are ignored. - * If no token is provided domain, clientId, clientSecret and scopes are required - * @param {String} options.domain ManagementClient server domain. - * @param {String} [options.token] API access token. - * @param {String} [options.clientId] Management API Non Interactive Client Id. - * @param {String} [options.clientSecret] Management API Non Interactive Client Secret. - * @param {String} [options.audience] Management API Audience. By default is your domain's, e.g. the domain is `tenant.auth0.com` and the audience is `http://tenant.auth0.com/api/v2/` - * @param {String} [options.scope] Management API Scopes. - * @param {Boolean} [options.tokenProvider.enableCache=true] Enabled or Disable Cache. - * @param {Number} [options.tokenProvider.cacheTTLInSeconds] By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden. - * @param {Boolean} [options.retry.enabled=true] Enabled or Disable Retry Policy functionality. - * @param {Number} [options.retry.maxRetries=10] Retry failed requests X times. - * */ -var ManagementClient = function(options) { - if (!options || typeof options !== 'object') { - throw new ArgumentError('Management API SDK options must be an object'); - } - - if (!options.domain || options.domain.length === 0) { - throw new ArgumentError('Must provide a domain'); - } - - var baseUrl = util.format(BASE_URL_FORMAT, options.domain); - var managerOptions = { - headers: { - 'User-agent': 'node.js/' + process.version.replace('v', ''), - 'Content-Type': 'application/json' - }, - baseUrl: baseUrl - }; - - if (options.token === undefined) { - var config = assign( - { audience: util.format(MANAGEMENT_API_AUD_FORMAT, options.domain) }, - options - ); - - if (options.tokenProvider) { - config.enableCache = options.tokenProvider.enableCache; - config.cacheTTLInSeconds = options.tokenProvider.cacheTTLInSeconds; - delete config.tokenProvider; +class ManagementClient { + /** + * @param {object} options Options for the ManagementClient SDK. + * If a token is provided only the domain is required, other parameters are ignored. + * If no token is provided domain, clientId, clientSecret and scopes are required + * @param {string} options.domain ManagementClient server domain. + * @param {string} [options.token] API access token. + * @param {string} [options.clientId] Management API Non Interactive Client Id. + * @param {string} [options.clientSecret] Management API Non Interactive Client Secret. + * @param {string} [options.audience] Management API Audience. By default is your domain's, e.g. the domain is `tenant.auth0.com` and the audience is `http://tenant.auth0.com/api/v2/` + * @param {string} [options.scope] Management API Scopes. + * @param {boolean} [options.tokenProvider.enableCache=true] Enabled or Disable Cache. + * @param {number} [options.tokenProvider.cacheTTLInSeconds] By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden. + * @param {boolean} [options.retry.enabled=true] Enabled or Disable Retry Policy functionality. + * @param {number} [options.retry.maxRetries=10] Retry failed requests X times. + * @param {object} [options.headers] Additional headers that will be added to the outgoing requests. + * @param {string} [options.proxy] Add the `superagent-proxy` dependency and specify a proxy url eg 'https://myproxy.com:1234' + * @param {boolean} [options.includeResponseHeaders] Include the response headers in the payload in the format `{ data, headers }`. + */ + constructor(options) { + if (!options || typeof options !== 'object') { + throw new ArgumentError('Management API SDK options must be an object'); + } + + if (!options.domain || options.domain.length === 0) { + throw new ArgumentError('Must provide a domain'); + } + + const baseUrl = util.format(BASE_URL_FORMAT, options.domain); + + const defaultHeaders = { + 'User-Agent': `node.js/${process.version.replace('v', '')}`, + 'Content-Type': 'application/json', + }; + + const managerOptions = { + headers: Object.assign(defaultHeaders, options.headers || {}), + baseUrl, + }; + + if (options.token === undefined) { + const config = Object.assign( + { audience: util.format(MANAGEMENT_API_AUD_FORMAT, options.domain) }, + options + ); + + if (options.tokenProvider) { + config.enableCache = options.tokenProvider.enableCache; + config.cacheTTLInSeconds = options.tokenProvider.cacheTTLInSeconds; + delete config.tokenProvider; + } + + this.tokenProvider = new ManagementTokenProvider(config); + } else if (typeof options.token !== 'string' || options.token.length === 0) { + throw new ArgumentError('Must provide a token'); + } else { + this.tokenProvider = { + getAccessToken() { + return Promise.resolve(options.token); + }, + }; + managerOptions.headers['Authorization'] = `Bearer ${options.token}`; } - this.tokenProvider = new ManagementTokenProvider(config); managerOptions.tokenProvider = this.tokenProvider; - } else if (typeof options.token !== 'string' || options.token.length === 0) { - throw new ArgumentError('Must provide a token'); - } else { - managerOptions.headers['Authorization'] = 'Bearer ' + options.token; - } - if (options.telemetry !== false) { - var telemetry = jsonToBase64(options.clientInfo || this.getClientInfo()); - managerOptions.headers['Auth0-Client'] = telemetry; + if (options.telemetry !== false) { + const clientInfo = options.clientInfo || generateClientInfo(); + if ('string' === typeof clientInfo.name && clientInfo.name.length > 0) { + const telemetry = jsonToBase64(clientInfo); + managerOptions.headers['Auth0-Client'] = telemetry; + } + } + + managerOptions.retry = options.retry; + managerOptions.includeResponseHeaders = options.includeResponseHeaders; + managerOptions.proxy = options.proxy; + + /** + * Simple abstraction for performing CRUD operations on the + * clients endpoint. + * + * @type {ClientsManager} + */ + this.clients = new ClientsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the client grants + * endpoint. + * + * @type {ClientGrantsManager} + */ + this.clientGrants = new ClientGrantsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the grants + * endpoint. + * + * @type {GrantsManager} + */ + this.grants = new GrantsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * users endpoint. + * + * @type {UsersManager} + */ + this.users = new UsersManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * user-blocks endpoint. + * + * @type {UserBlocksManager} + */ + this.userBlocks = new UserBlocksManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * guardian endpoint. + * + * @type {GuardianManager} + */ + this.guardian = new GuardianManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * custom domains endpoint. + * + * @type {CustomDomainsManager} + */ + this.customDomains = new CustomDomainsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * connections endpoint. + * + * @type {ConnectionsManager} + */ + this.connections = new ConnectionsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * device credentials endpoint. + * + * @type {DeviceCredentialsManager} + */ + this.deviceCredentials = new DeviceCredentialsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * rules endpoint. + * + * @type {RulesManager} + */ + this.rules = new RulesManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * blacklisted tokens endpoint. + * + * @type {BlacklistedTokensManager} + */ + this.blacklistedTokens = new BlacklistedTokensManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * email provider endpoint. + * + * @type {EmailProviderManager} + */ + this.emailProvider = new EmailProviderManager(managerOptions); + + /** + * ManagementClient account statistics manager. + * + * @type {StatsManager} + */ + this.stats = new StatsManager(managerOptions); + + /** + * ManagementClient tenant settings manager. + * + * @type {TenantManager} + */ + this.tenant = new TenantManager(managerOptions); + + /** + * Jobs manager. + * + * @type {JobsManager} + */ + this.jobs = new JobsManager(managerOptions); + + /** + * Tickets manager. + * + * @type {TicketsManager} + */ + this.tickets = new TicketsManager(managerOptions); + + /** + * Logs manager. + * + * @type {LogsManager} + */ + this.logs = new LogsManager(managerOptions); + + /** + * Log Streams manager. + * + * @type {LogStreamsManager} + */ + this.logStreams = new LogStreamsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * resource servers endpoint. + * + * @type {ResourceServersManager} + */ + this.resourceServers = new ResourceServersManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on + * Auth0's Email Templates + * + * @type {EmailTemplatesManager} + */ + this.emailTemplates = new EmailTemplatesManager(managerOptions); + + /** + * RulesConfigs manager. + * + * @type {RulesConfigsManager} + */ + this.rulesConfigs = new RulesConfigsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * roles endpoint. + * + * @type {RolesManager} + */ + this.roles = new RolesManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * hooks endpoint. + * + * @type {HooksManager} + */ + this.hooks = new HooksManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * branding endpoint. + * + * @type {BrandingManager} + */ + this.branding = new BrandingManager(managerOptions); + + /** + * ManagementClient migrations manager. + * + * @type {MigrationsManager} + */ + this.migrations = new MigrationsManager(managerOptions); + + /** + * Prompts Manager + * + * @type {PromptsManager} + */ + this.prompts = new PromptsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * actions endpoint. + * + * @type {ActionsManager} + */ + this.actions = new ActionsManager(managerOptions); + + /** + * Organizations Manager + * + * @type {OrganizationsManager} + */ + this.organizations = new OrganizationsManager(managerOptions); + + /** + * Attack Protection Manager + * + * @type {AttackProtectionManager} + */ + this.attackProtection = new AttackProtectionManager(managerOptions); } - managerOptions.retry = options.retry; + /** + * Get all connections. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getConnections(params, function (err, connections) { + * console.log(connections.length); + * }); + * @param {object} [params] Connections params. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getConnections(...args) { + return this.connections.getAll(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * clients endpoint. + * Create a new connection. * - * @type {ClientsManager} + * @example + * management.createConnection(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Connection created. + * }); + * @param {object} data Connection data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.clients = new ClientsManager(managerOptions); + + createConnection(...args) { + return this.connections.create(...args); + } /** - * Simple abstraction for performing CRUD operations on the client grants - * endpoint. + * Get an Auth0 connection. + * + * @example + * management.getConnection({ id: CONNECTION_ID }, function (err, connection) { + * if (err) { + * // Handle error. + * } * - * @type {ClientGrantsManager} + * console.log(connection); + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.clientGrants = new ClientGrantsManager(managerOptions); + getConnection(...args) { + return this.connections.get(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * users endpoint. + * Delete an existing connection. + * + * @example + * management.deleteConnection({ id: CONNECTION_ID }, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {UsersManager} + * // Connection deleted. + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.users = new UsersManager(managerOptions); + deleteConnection(...args) { + return this.connections.delete(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * guardian endpoint. + * Update an existing connection. + * + * @example + * var data = { name: 'newConnectionName' }; + * var params = { id: CONNECTION_ID }; * - * @type {GuardianManager} + * management.updateConnection(params, data, function (err, connection) { + * if (err) { + * // Handle error. + * } + * + * console.log(connection.name); // 'newConnectionName' + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {object} data Updated connection data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.guardian = new GuardianManager(managerOptions); + updateConnection(...args) { + return this.connections.update(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * custom domains endpoint. + * Get all Auth0 clients. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; * - * @type {CustomDomainsManager} + * management.getClients(params, function (err, clients) { + * console.log(clients.length); + * }); + * @param {object} [params] Clients parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.customDomains = new CustomDomainsManager(managerOptions); + getClients(...args) { + return this.clients.getAll(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * connections endpoint. + * Get an Auth0 client. + * + * @example + * management.getClient({ client_id: CLIENT_ID }, function (err, client) { + * if (err) { + * // Handle error. + * } * - * @type {ConnectionsManager} + * console.log(client); + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {string} params.fields Comma-separated list of fields to include or exclude (based on value provided for include_fields). + * @param {string} params.include_fields Whether specified fields are to be included (true) or excluded (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.connections = new ConnectionsManager(managerOptions); + getClient(...args) { + return this.clients.get(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * device credentials endpoint. + * Create an Auth0 client. + * + * @example + * management.createClient(data, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {DeviceCredentialsManager} + * // Client created. + * }); + * @param {object} data The client data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.deviceCredentials = new DeviceCredentialsManager(managerOptions); + createClient(...args) { + return this.clients.create(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * rules endpoint. + * Update an Auth0 client. + * + * @example + * var data = { name: 'newClientName' }; + * var params = { client_id: CLIENT_ID }; * - * @type {RulesManager} + * management.updateClient(params, data, function (err, client) { + * if (err) { + * // Handle error. + * } + * + * console.log(client.name); // 'newClientName' + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {object} data Updated client data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.rules = new RulesManager(managerOptions); + updateClient(...args) { + return this.clients.update(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * blacklisted tokens endpoint. + * Delete an Auth0 client. * - * @type {BlacklistedtokensManager} + * @example + * management.deleteClient({ client_id: CLIENT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Client deleted. + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.blacklistedTokens = new BlacklistedTokensManager(managerOptions); + deleteClient(...args) { + return this.clients.delete(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * email provider endpoint. + * Get all Auth0 Client Grants. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; * - * @type {EmailProviderManager} + * management.getClientGrants(params, function (err, grants) { + * console.log(grants.length); + * }); + * @param {object} [params] Client Grants parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.emailProvider = new EmailProviderManager(managerOptions); + getClientGrants(...args) { + return this.clientGrants.getAll(...args); + } /** - * ManagementClient account statistics manager. + * Create an Auth0 client grant. + * + * @example + * management.clientGrants.create(data, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {StatsManager} + * // Client grant created. + * }); + * @param {object} data The client data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.stats = new StatsManager(managerOptions); + createClientGrant(...args) { + return this.clientGrants.create(...args); + } /** - * ManagementClient tenant settings manager. + * Update an Auth0 client grant. + * + * @example + * var data = { + * client_id: CLIENT_ID, + * audience: AUDIENCE, + * scope: [] + * }; + * var params = { id: CLIENT_GRANT_ID }; * - * @type {TenantManager} + * management.clientGrants.update(params, data, function (err, grant) { + * if (err) { + * // Handle error. + * } + * + * console.log(grant.id); + * }); + * @param {object} params Client parameters. + * @param {string} params.id Client grant ID. + * @param {object} data Updated client data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.tenant = new TenantManager(managerOptions); + updateClientGrant(...args) { + return this.clientGrants.update(...args); + } /** - * Jobs manager. + * Delete an Auth0 client grant. * - * @type {JobsManager} + * @example + * management.clientGrants.delete({ id: GRANT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Grant deleted. + * }); + * @param {object} params Client parameters. + * @param {string} params.id Client grant ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.jobs = new JobsManager(managerOptions); + deleteClientGrant(...args) { + return this.clientGrants.delete(...args); + } /** - * Tickets manager. + * Get all Auth0 Grants. * - * @type {TicketsManager} + * @example + * var params = { + * per_page: 10, + * page: 0, + * include_totals: true, + * user_id: USER_ID, + * client_id: CLIENT_ID, + * audience: AUDIENCE + * }; + * + * management.getGrants(params, function (err, grants) { + * console.log(grants.length); + * }); + * @param {object} params Grants parameters. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {string} params.user_id The user_id of the grants to retrieve. + * @param {string} params.client_id The client_id of the grants to retrieve. + * @param {string} params.audience The audience of the grants to retrieve. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.tickets = new TicketsManager(managerOptions); + getGrants(...args) { + return this.grants.getAll(...args); + } /** - * Logs manager. + * Delete an Auth0 grant. + * + * @example + * var params = { + * id: GRANT_ID, + * user_id: USER_ID + * }; + * + * management.deleteGrant(params, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {LogsManager} + * // Grant deleted. + * }); + * @param {object} params Grant parameters. + * @param {string} params.id Grant ID. + * @param {string} params.user_id The user_id of the grants to delete. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.logs = new LogsManager(managerOptions); + deleteGrant(...args) { + return this.grants.delete(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * resource servers endpoint. + * Create an Auth0 credential. + * + * @example + * management.createConnection(data, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {ResourceServersManager} + * // Credential created. + * }); + * @param {object} data The device credential data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.resourceServers = new ResourceServersManager(managerOptions); + createDevicePublicKey(...args) { + return this.deviceCredentials.createPublicKey(...args); + } /** - * Simple abstraction for performing CRUD operations on - * Auth0's Email Templates + * Get all Auth0 credentials. + * + * @example + * var params = {user_id: "USER_ID"}; * - * @type {EmailTemplatesManager} + * management.getDeviceCredentials(params, function (err, credentials) { + * console.log(credentials.length); + * }); + * @param {object} params Credential parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.emailTemplates = new EmailTemplatesManager(managerOptions); + getDeviceCredentials(...args) { + return this.deviceCredentials.getAll(...args); + } /** - * RulesConfigs manager. + * Delete an Auth0 device credential. + * + * @example + * var params = { id: CREDENTIAL_ID }; * - * @type {RulesConfigsManager} + * management.deleteDeviceCredential(params, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Credential deleted. + * }); + * @param {object} params Credential parameters. + * @param {string} params.id Device credential ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.rulesConfigs = new RulesConfigsManager(managerOptions); -}; + deleteDeviceCredential(...args) { + return this.deviceCredentials.delete(...args); + } -/** - * Return an object with information about the current client, - * - * @method getClientInfo - * @memberOf module:management.ManagementClient.prototype - * - * @return {Object} Object containing client information. - */ -ManagementClient.prototype.getClientInfo = function() { - var clientInfo = { - name: 'node-auth0', - version: pkg.version, - dependencies: [], - environment: [ - { - name: 'node.js', - version: process.version.replace('v', '') - } - ] - }; - // Add the dependencies to the client info object. - Object.keys(pkg.dependencies).forEach(function(name) { - clientInfo.dependencies.push({ - name: name, - version: pkg.dependencies[name] - }); - }); - - return clientInfo; -}; + /** + * Get all rules. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getRules(params, function (err, rules) { + * console.log(rules.length); + * }); + * @param {object} [params] Rules parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRules(...args) { + return this.rules.getAll(...args); + } -/** - * Get all connections. - * - * @method getConnections - * @memberOf module:management.ManagementClient.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getConnections(params, function (err, connections) { - * console.log(connections.length); - * }); - * - * @param {Object} [params] Connections params. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getConnections', 'connections.getAll'); + /** + * Create a new rule. + * + * @example + * management.createRule(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Rule created. + * }); + * @param {object} data Rule data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createRule(...args) { + return this.rules.create(...args); + } -/** - * Create a new connection. - * - * @method createConnection - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createConnection(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Conection created. - * }); - * - * @param {Object} data Connection data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createConnection', 'connections.create'); + /** + * Get an Auth0 rule. + * + * @example + * management.getRule({ id: RULE_ID }, function (err, rule) { + * if (err) { + * // Handle error. + * } + * + * console.log(rule); + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRule(...args) { + return this.rules.get(...args); + } -/** - * Get an Auth0 connection. - * - * @method getConnection - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getConnection({ id: CONNECTION_ID }, function (err, connection) { - * if (err) { - * // Handle error. - * } - * - * console.log(connection); - * }); - * - * @param {Object} params Connection parameters. - * @param {String} params.id Connection ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getConnection', 'connections.get'); + /** + * Delete an existing rule. + * + * @example + * auth0.deleteRule({ id: RULE_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Rule deleted. + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteRule(...args) { + return this.rules.delete(...args); + } -/** - * Delete an existing connection. - * - * @method deleteConnection - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteConnection({ id: CONNECTION_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Conection deleted. - * }); - * - * @param {Object} params Connection parameters. - * @param {String} params.id Connection ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteConnection', 'connections.delete'); + /** + * Update an existing rule. + * + * @example + * var params = { id: RULE_ID }; + * var data = { name: 'my-rule'}; + * management.updateRule(params, data, function (err, rule) { + * if (err) { + * // Handle error. + * } + * + * console.log(rule.name); // 'my-rule'. + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {object} data Updated rule data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateRule(...args) { + return this.rules.update(...args); + } -/** - * Update an existing connection. - * - * @method updateConnection - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var data = { name: 'newConnectionName' }; - * var params = { id: CONNECTION_ID }; - * - * management.updateConnection(params, data, function (err, connection) { - * if (err) { - * // Handle error. - * } - * - * console.log(connection.name); // 'newConnectionName' - * }); - * - * @param {Object} params Connection parameters. - * @param {String} params.id Connection ID. - * @param {Object} data Updated connection data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateConnection', 'connections.update'); + /** + * Get all users. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * search_engine: 'v3', + * q: 'name:*jane*', + * per_page: 10, + * page: 0 + * }; + * + * auth0.getUsers(params, function (err, users) { + * console.log(users.length); + * }); + * @param {object} [params] Users params. + * @param {number} [params.search_engine] The version of the search engine to use. + * @param {string} [params.q] User Search string to filter which users are returned. Follows Lucene query string syntax as documented at https://auth0.com/docs/api/management/v2#!/Users/get_users. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUsers(...args) { + return this.users.getAll(...args); + } -/** - * Get all Auth0 clients. - * - * @method getClients - * @memberOf module:management.ManagementClient.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getClients(params, function (err, clients) { - * console.log(clients.length); - * }); - * - * @param {Object} [params] Clients parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getClients', 'clients.getAll'); + /** + * Get users for a given email address + * + * @example <caption> + * This method takes an email address as the first argument, + * and returns all users with that email address + * </caption> + * + * auth0.getUsersByEmail(email, function (err, users) { + * console.log(users); + * }); + * @param {string} [email] Email address of user(s) to find + * @param {object} [options] Additional options to pass to the endpoint + * @param {string} [options.fields] Comma-separated list of fields to include or exclude in the result + * @param {boolean} [options.include_fields] Whether specified fields are to be included (true) or excluded (false). Defaults to true. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUsersByEmail(...args) { + return this.users.getByEmail(...args); + } -/** - * Get an Auth0 client. - * - * @method getClient - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getClient({ client_id: CLIENT_ID }, function (err, client) { - * if (err) { - * // Handle error. - * } - * - * console.log(client); - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getClient', 'clients.get'); + /** + * Get a user by its id. + * + * @example + * management.getUser({ id: USER_ID }, function (err, user) { + * console.log(user); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUser(...args) { + return this.users.get(...args); + } -/** - * Create an Auth0 client. - * - * @method createClient - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createClient(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client created. - * }); - * - * @param {Object} data The client data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createClient', 'clients.create'); + /** + * Delete all users. + * + * @example + * management.deleteAllUsers(function (err) { + * if (err) { + * // Handle error. + * } + * + * // Users deleted + * }); + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + * @deprecated This method will be removed in the next major release. + */ + deleteAllUsers(...args) { + return this.users.deleteAll(...args); + } -/** - * Update an Auth0 client. - * - * @method updateClient - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var data = { name: 'newClientName' }; - * var params = { client_id: CLIENT_ID }; - * - * management.updateClient(params, data, function (err, client) { - * if (err) { - * // Handle error. - * } - * - * console.log(client.name); // 'newClientName' - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Object} data Updated client data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateClient', 'clients.update'); + /** + * Delete a user by its id. + * + * @example + * management.deleteUser({ id: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User deleted. + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + deleteUser(...args) { + return this.users.delete(...args); + } -/** - * Delete an Auth0 client. - * - * @method deleteClient - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteClient({ client_id: CLIENT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client deleted. - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteClient', 'clients.delete'); + /** + * Create a new user. + * + * @example + * management.createUser(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User created. + * }); + * @param {object} data User data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createUser(...args) { + return this.users.create(...args); + } -/** - * Get all Auth0 Client Grants. - * - * @method getAll - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getClientGrants(params, function (err, grants) { - * console.log(grants.length); - * }); - * - * @param {Object} [params] Client Grants parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getClientGrants', 'clientGrants.getAll'); + /** + * Update a user by its id. + * + * @example + * var params = { id: USER_ID }; + * + * management.updateUser(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user parameters. + * @param {string} params.id The user id. + * @param {object} data New user data. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateUser(...args) { + return this.users.update(...args); + } -/** - * Create an Auth0 client grant. - * - * @method create - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * management.clientGrants.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client grant created. - * }); - * - * @param {Object} data The client data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createClientGrant', 'clientGrants.create'); + /** + * Update the user metadata for a user. + * + * @example + * var params = { id: USER_ID }; + * var metadata = { + * address: '123th Node.js Street' + * }; + * + * management.updateUserMetadata(params, metadata, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {object} metadata New user metadata. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateUserMetadata(...args) { + return this.users.updateUserMetadata(...args); + } -/** - * Update an Auth0 client grant. - * - * @method update - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * var data = { - * client_id: CLIENT_ID, - * audience: AUDIENCE, - * scope: [] - * }; - * var params = { id: CLIENT_GRANT_ID }; - * - * management.clientGrants.update(params, data, function (err, grant) { - * if (err) { - * // Handle error. - * } - * - * console.log(grant.id); - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.id Client grant ID. - * @param {Object} data Updated client data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateClientGrant', 'clientGrants.update'); + /** + * Update the app metadata for a user. + * + * @example + * var params = { id: USER_ID }; + * var metadata = { + * foo: 'bar' + * }; + * + * management.updateAppMetadata(params, metadata, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {object} metadata New app metadata. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateAppMetadata(...args) { + return this.users.updateAppMetadata(...args); + } -/** - * Delete an Auth0 client grant. - * - * @method delete - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * management.clientGrants.delete({ id: GRANT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Grant deleted. - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.id Client grant ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteClientGrant', 'clientGrants.delete'); + /** + * Delete a multifactor provider for a user. + * + * @example + * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; + * + * management.deleteUserMultifactor(params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users accounts unlinked. + * }); + * @param {object} params Data object. + * @param {string} params.id The user id. + * @param {string} params.provider Multifactor provider. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + deleteUserMultifactor(...args) { + return this.users.deleteMultifactorProvider(...args); + } -/** - * Create an Auth0 credential. - * - * @method createDevicePublicKey - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createConnection(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Credential created. - * }); - * - * @param {Object} data The device credential data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'createDevicePublicKey', - 'deviceCredentials.createPublicKey' -); + /** + * Delete a multifactor provider for a user. + * + * @example + * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; + * + * management.deleteUserMultifcator(params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users accounts unlinked. + * }); + * @param {object} params Data object. + * @param {string} params.id The user id. + * @param {string} params.provider Multifactor provider. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + * @deprecated The function name has a typo. + * We're shipping this so it doesn't break compatibility. + * Use {@link deleteUserMultifactor} instead. + */ + deleteUserMultifcator(...args) { + return this.users.deleteMultifactorProvider(...args); + } -/** - * Get all Auth0 credentials. - * - * @method getDeviceCredentials - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getDeviceCredentials(function (err, credentials) { - * console.log(credentials.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getDeviceCredentials', 'deviceCredentials.getAll'); + /** + * Unlink the given accounts. + * + * @example + * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID }; + * + * management.unlinkUsers(params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users accounts unlinked. + * }); + * @param {object} params Linked users data. + * @param {string} params.id Primary user ID. + * @param {string} params.provider Identity provider in use. + * @param {string} params.user_id Secondary user ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + unlinkUsers(...args) { + return this.users.unlink(...args); + } -/** - * Delete an Auth0 device credential. - * - * @method deleteDeviceCredential - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: CREDENTIAL_ID }; - * - * management.deleteDeviceCredential(params, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Credential deleted. - * }); - * - * @param {Object} params Credential parameters. - * @param {String} params.id Device credential ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteDeviceCredential', 'deviceCredentials.delete'); + /** + * Link the user with another account. + * + * @example + * var userId = 'USER_ID'; + * var params = { + * user_id: 'OTHER_USER_ID', + * connection_id: 'CONNECTION_ID' + * }; + * + * management.linkUsers(userId, params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users linked. + * }); + * @param {string} userId ID of the primary user. + * @param {object} params Secondary user data. + * @param {string} params.user_id ID of the user to be linked. + * @param {string} params.connection_id ID of the connection to be used. + * @param {string} params.provider Identity provider of the secondary user account being linked. + * @param {string} params.link_with JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + linkUsers(...args) { + return this.users.link(...args); + } -/** - * Get all rules. - * - * @method getRules - * @memberOf module:management.ManagementClient.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getRules(params, function (err, rules) { - * console.log(rules.length); - * }); - * - * @param {Object} [params] Rules parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getRules', 'rules.getAll'); + /** + * Get user's log events. + * + * @example + * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; + * + * management.getUserLogs(params, function (err, logs) { + * if (err) { + * // Handle error. + * } + * + * console.log(logs); + * }); + * @param {object} params Get logs data. + * @param {string} params.id User id. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUserLogs(...args) { + return this.users.logs(...args); + } -/** - * Create a new rule. - * - * @method createRule - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createRule(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rule created. - * }); - * - * @param {Object} data Rule data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createRule', 'rules.create'); + /** + * Get user's roles + * + * @example + * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; + * + * management.getUserRoles(params, function (err, logs) { + * if (err) { + * // Handle error. + * } + * + * console.log(logs); + * }); + * @param {object} params Get roles data. + * @param {string} params.id User id. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUserRoles(...args) { + return this.users.getRoles(...args); + } -/** - * Get an Auth0 rule. - * - * @method getRule - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getRule({ id: RULE_ID }, function (err, rule) { - * if (err) { - * // Handle error. - * } - * - * console.log(rule); - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getRule', 'rules.get'); + /** + * Assign roles to a user + * + * @example + * var parms = { id : 'USER_ID'}; + * var data = { "roles" :["role1"]}; + * + * management.assignRolestoUser(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User assigned roles. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {object} data data object containing list of role IDs + * @param {string} data.roles Array of role IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + assignRolestoUser(...args) { + return this.users.assignRoles(...args); + } + + /** + * Assign users to a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "users" : ["userId1","userId2"]}; + * + * management.roles.assignUsers(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // permissions added. + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + assignUsersToRole(...args) { + return this.roles.assignUsers(...args); + } + + /** + * Remove roles from a user + * + * @example + * var parms = { id : 'USER_ID'}; + * var data = { "roles" :["role1"]}; + * + * management.removeRolesFromUser(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User assigned roles. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of role IDs + * @param {string} data.roles Array of role IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removeRolesFromUser(...args) { + return this.users.removeRoles(...args); + } + + /** + * Get user's permissions + * + * @example + * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; + * + * management.getUserPermissions(params, function (err, logs) { + * if (err) { + * // Handle error. + * } + * + * console.log(logs); + * }); + * @param {object} params Get permissions data. + * @param {string} params.id User id. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUserPermissions(...args) { + return this.users.getPermissions(...args); + } + + /** + * Assign permissions to a user + * + * @example + * var parms = { id : 'USER_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.assignPermissionsToUser(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User assigned permissions. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of permissions + * @param {string} data.permissions Array of permission IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + assignPermissionsToUser(...args) { + return this.users.assignPermissions(...args); + } + + /** + * Remove permissions from a user + * + * @example + * var parms = { id : 'USER_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.removePermissionsFromUser(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User assigned permissions. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of permission IDs + * @param {string} data.permissions Array of permission IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removePermissionsFromUser(...args) { + return this.users.removePermissions(...args); + } + + /** + * Get a list of a user's Guardian enrollments. + * + * @example + * management.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) { + * console.log(enrollments); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianEnrollments(...args) { + return this.users.getGuardianEnrollments(...args); + } + + /** + * Generate new Guardian recovery code. + * + * @example + * management.regenerateRecoveryCode({ id: USER_ID }, function (err, newRecoveryCode) { + * console.log(newRecoveryCode); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + regenerateRecoveryCode(...args) { + return this.users.regenerateRecoveryCode(...args); + } + + /** + * Invalidate all remembered browsers for MFA. + * + * @example + * management.invalidateRememberBrowser({ id: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Invalidated all remembered browsers. + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + invalidateRememberBrowser(...args) { + return this.users.invalidateRememberBrowser(...args); + } + + /** + * Get user blocks by its id. + * + * @example + * management.getUserBlocks({ id: USER_ID }, function (err, blocks) { + * if (err) { + * // Handle error. + * } + * + * console.log(blocks); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + getUserBlocks(...args) { + return this.userBlocks.get(...args); + } + + /** + * Unblock an user by its id. + * + * @example + * management.unblockUser({ id: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User unblocked. + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + unblockUser(...args) { + return this.userBlocks.delete(...args); + } + + /** + * Get user blocks by its identifier. + * + * @example + * management.getUserBlocksByIdentifier({ identifier: USER_ID }, function (err, blocks) { + * if (err) { + * // Handle error. + * } + * + * console.log(blocks); + * }); + * @param {object} params The user data object.. + * @param {string} params.identifier The user identifier, any of: username, phone_number, email. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + getUserBlocksByIdentifier(...args) { + return this.userBlocks.getByIdentifier(...args); + } + + /** + * Unblock an user by its id. + * + * @example + * management.unblockUserByIdentifier({ identifier: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User unblocked. + * }); + * @param {object} params The user data object.. + * @param {string} params.identifier The user identifier, any of: username, phone_number, email. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + unblockUserByIdentifier(...args) { + return this.userBlocks.deleteByIdentifier(...args); + } + + /** + * Get a single Guardian enrollment. + * + * @example + * management.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) { + * console.log(enrollment); + * }); + * @param {object} data The Guardian enrollment data object. + * @param {string} data.id The Guardian enrollment id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianEnrollment(...args) { + return this.guardian.getGuardianEnrollment(...args); + } + + /** + * Delete a user's Guardian enrollment. + * + * @example + * management.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email provider deleted. + * }); + * @param {object} data The Guardian enrollment data object. + * @param {string} data.id The Guardian enrollment id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteGuardianEnrollment(...args) { + return this.guardian.deleteGuardianEnrollment(...args); + } + + /** + * Get all blacklisted tokens. + * + * @example + * management.getBlacklistedTokens(function (err, tokens) { + * console.log(tokens.length); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getBlacklistedTokens(...args) { + return this.blacklistedTokens.getAll(...args); + } + + /** + * Blacklist a new token. + * + * @example + * var token = { + * aud: 'aud', + * jti: 'jti' + * }; + * + * management.blacklistToken(token, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Token blacklisted. + * }); + * @param {object} token Token data. + * @param {string} token.aud Audience (your app client ID). + * @param {string} token.jti The JWT ID claim. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + blacklistToken(...args) { + return this.blacklistedTokens.add(...args); + } + + /** + * Create a new Email Template. + * + * @example + * management.createEmailTemplate(data, function (err) { + * if (err) { + * // Handle error. + * // Email Template created. + * }); + * @param {object} data Email Template data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createEmailTemplate(...args) { + return this.emailTemplates.create(...args); + } + + /** + * Get an Auth0 Email Template. + * + * @example + * management.getEmailTemplate({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) { + * if (err) { + * // Handle error. + * } + * + * console.log(emailTemplate); + * }); + * @param {object} params Email Template parameters. + * @param {string} params.name Template Name + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getEmailTemplate(...args) { + return this.emailTemplates.get(...args); + } + + /** + * Update an existing Email Template. + * + * @example + * var data = { from: 'new@email.com' }; + * var params = { name: EMAIL_TEMPLATE_NAME }; + * + * management.updateEmailTemplates(params, data, function (err, emailTemplate) { + * if (err) { + * // Handle error. + * } + * + * console.log(emailTemplate.from); // 'new@email.com' + * }); + * @param {object} params Email Template parameters. + * @param {string} params.name Template Name + * @param {object} data Updated Email Template data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateEmailTemplate(...args) { + return this.emailTemplates.update(...args); + } + + /** + * Get the email provider. + * + * @example + * management.getEmailProvider(function (err, provider) { + * console.log(provider.length); + * }); + * @param {Function} [cb] Callback function. + * @param {object} [params] Clients parameters. + * @param {number} [params.fields] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields. + * @param {number} [params.include_fields] true if the fields specified are to be excluded from the result, false otherwise (defaults to true) + * @returns {Promise|undefined} + */ + getEmailProvider(...args) { + return this.emailProvider.get(...args); + } + + /** + * Configure the email provider. + * + * @example + * management.configureEmailProvider(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email provider configured. + * }); + * @param {object} data The email provider data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + configureEmailProvider(...args) { + return this.emailProvider.configure(...args); + } + + /** + * Delete email provider. + * + * @example + * management.deleteEmailProvider(function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email provider deleted. + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteEmailProvider(...args) { + return this.emailProvider.delete(...args); + } + + /** + * Update the email provider. + * + * @example + * management.updateEmailProvider(params, data, function (err, provider) { + * if (err) { + * // Handle error. + * } + * + * // Updated email provider. + * console.log(provider); + * }); + * @param {object} params Email provider parameters. + * @param {object} data Updated email provider data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateEmailProvider(...args) { + return this.emailProvider.update(...args); + } + + /** + * Get a the active users count. + * + * @example + * management.getActiveUsersCount(function (err, usersCount) { + * if (err) { + * // Handle error. + * } + * + * console.log(usersCount); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getActiveUsersCount(...args) { + return this.stats.getActiveUsersCount(...args); + } + + /** + * Get the daily stats. + * + * @example + * var params = { + * from: '{YYYYMMDD}', // First day included in the stats. + * to: '{YYYYMMDD}' // Last day included in the stats. + * }; + * + * management.getDaily(params, function (err, stats) { + * if (err) { + * // Handle error. + * } + * + * console.log(stats); + * }); + * @param {object} params Stats parameters. + * @param {string} params.from The first day in YYYYMMDD format. + * @param {string} params.to The last day in YYYYMMDD format. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getDailyStats(...args) { + return this.stats.getDaily(...args); + } + + /** + * Get the tenant settings.. + * + * @example + * management.getSettings(function (err, settings) { + * if (err) { + * // Handle error. + * } + * + * console.log(settings); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getTenantSettings(...args) { + return this.tenant.getSettings(...args); + } + + /** + * Update the tenant settings. + * + * @example + * management.updateTenantSettings(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data The new tenant settings. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateTenantSettings(...args) { + return this.tenant.updateSettings(...args); + } + + /** + * Get a job by its ID. + * + * @example + * var params = { + * id: '{JOB_ID}' + * }; + * + * management.getJob(params, function (err, job) { + * if (err) { + * // Handle error. + * } + * + * // Retrieved job. + * console.log(job); + * }); + * @param {object} params Job parameters. + * @param {string} params.id Job ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getJob(...args) { + return this.jobs.get(...args); + } + + /** + * Given a path to a file and a connection id, create a new job that imports the + * users contained in the file or JSON string and associate them with the given + * connection. + * + * @example + * var params = { + * connection_id: '{CONNECTION_ID}', + * users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}' + * }; + * + * management.importUsers(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data Users import data. + * @param {string} data.connection_id connection_id of the connection to which users will be imported. + * @param {string} [data.users] Path to the users data file. Either users or users_json is mandatory. + * @param {string} [data.users_json] JSON data for the users. + * @param {boolean} [data.upsert] Whether to update users if they already exist (true) or to ignore them (false). + * @param {boolean} [data.send_completion_email] Whether to send a completion email to all tenant owners when the job is finished (true) or not (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + importUsers(...args) { + return this.jobs.importUsers(...args); + } + + /** + * Given a path to a file and a connection id, create a new job that imports the + * users contained in the file or JSON string and associate them with the given + * connection. + * + * @example + * var params = { + * connection_id: '{CONNECTION_ID}', + * users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}' + * }; + * + * management.importUsersJob(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data Users import data. + * @param {string} data.connection_id connection_id of the connection to which users will be imported. + * @param {string} [data.users] Path to the users data file. Either users or users_json is mandatory. + * @param {string} [data.users_json] JSON data for the users. + * @param {boolean} [data.upsert] Whether to update users if they already exist (true) or to ignore them (false). + * @param {boolean} [data.send_completion_email] Whether to send a completion email to all tenant owners when the job is finished (true) or not (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + importUsersJob(...args) { + return this.jobs.importUsersJob(...args); + } + + /** + * Export all users to a file using a long running job. + * + * @example + * var data = { + * connection_id: 'con_0000000000000001', + * format: 'csv', + * limit: 5, + * fields: [ + * { + * "name": "user_id" + * }, + * { + * "name": "name" + * }, + * { + * "name": "email" + * }, + * { + * "name": "identities[0].connection", + * "export_as": "provider" + * }, + * { + * "name": "user_metadata.some_field" + * } + * ] + * } + * + * management.exportUsers(data, function (err, results) { + * if (err) { + * // Handle error. + * } + * + * // Retrieved job. + * console.log(results); + * }); + * @param {object} data Users export data. + * @param {string} [data.connection_id] The connection id of the connection from which users will be exported + * @param {string} [data.format] The format of the file. Valid values are: "json" and "csv". + * @param {number} [data.limit] Limit the number of records. + * @param {object[]} [data.fields] A list of fields to be included in the CSV. If omitted, a set of predefined fields will be exported. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + exportUsers(...args) { + return this.jobs.exportUsers(...args); + } + + /** + * Given a job ID, retrieve the failed/errored items + * + * @example + * var params = { + * id: '{JOB_ID}' + * }; + * + * management.jobs.errors(params, function (err, job) { + * if (err) { + * // Handle error. + * } + * + * // Retrieved job. + * console.log(job); + * }); + * @param {object} params Job parameters. + * @param {string} params.id Job ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getJobErrors(...args) { + return this.jobs.errors(...args); + } + + /** + * Send a verification email to a user. + * + * @example + * var params = { + * user_id: '{USER_ID}' + * }; + * + * management.sendEmailVerification(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data User data object. + * @param {string} data.user_id ID of the user to be verified. + * @param {string} [data.organization_id] Organization ID + * @param {string} [data.client_id] client_id of the client (application). If no value provided, the global Client ID will be used. + * @param {object} [data.identity] Used to verify secondary, federated, and passwordless-email identities. + * @param {string} data.identity.user_id user_id of the identity. + * @param {string} data.identity.provider provider of the identity. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + sendEmailVerification(...args) { + return this.jobs.verifyEmail(...args); + } + + /** + * Create a new password change ticket. + * + * @example + * + * var params = { + * result_url: '{REDIRECT_URL}', // Redirect after using the ticket. + * user_id: '{USER_ID}' + * }; + * + * // or + * + * var params = { + * result_url: '{REDIRECT_URL}', // Redirect after using the ticket. + * email: '{USER_EMAIL}', + * connection_id: '{CONNECTION}' // eg. con_00000000001 + * }; + * + * auth0.createPasswordChangeTicket(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise} + */ + createPasswordChangeTicket(...args) { + return this.tickets.changePassword(...args); + } + + /** + * Create an email verification ticket. + * + * @example + * var data = { + * user_id: '{USER_ID}', + * result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used. + * }; + * + * auth0.createEmailVerificationTicket(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise} + */ + createEmailVerificationTicket(...args) { + return this.tickets.verifyEmail(...args); + } + + /** + * Get an Auth0 log. + * + * @example + * management.getLog({ id: EVENT_ID }, function (err, log) { + * if (err) { + * // Handle error. + * } + * + * console.log(log); + * }); + * @param {object} params Log parameters. + * @param {string} params.id Event ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getLog(...args) { + return this.logs.get(...args); + } + + /** + * Get all logs. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings and the search query. If pagination options are + * not present, the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 2 + * }; + * + * management.getLogs(params, function (err, logs) { + * console.log(logs.length); + * }); + * @param {object} [params] Logs params. + * @param {string} [params.q] Search Criteria using Query String Syntax + * @param {number} [params.page] Page number. Zero based + * @param {number} [params.per_page] The amount of entries per page + * @param {string} [params.sort] The field to use for sorting. + * @param {string} [params.fields] A comma separated list of fields to include or exclude + * @param {boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise. + * @param {boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getLogs(...args) { + return this.logs.getAll(...args); + } + + /** + * Get all Log Streams. + * + * + * + * management.getLogStreams( function (err, logStreams) { + * console.log(logStreams.length); + * }); + * + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getLogStreams(...args) { + return this.logStreams.getAll(...args); + } -/** - * Delete an existing rule. - * - * @method deleteRule - * @memberOf module:management.ManagementClient.prototype - * - * @example - * auth0.deleteRule({ id: RULE_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rule deleted. - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteRule', 'rules.delete'); + /** + * Create a new Log Stream. + * + * @example + * management.createLogStream(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Log Stream created. + * }); + * @param {object} data Log Stream data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createLogStream(...args) { + return this.logStreams.create(...args); + } -/** - * Update an existing rule. - * - * @method updateRule - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: RULE_ID }; - * var data = { name: 'my-rule'}; - * management.updateRule(params, data, function (err, rule) { - * if (err) { - * // Handle error. - * } - * - * console.log(rule.name); // 'my-rule'. - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Object} data Updated rule data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateRule', 'rules.update'); + /** + * Get an Auth0 Log Stream. + * + * @example + * management.getLogStream({ id: LOG_STREAM_ID }, function (err, logStream) { + * if (err) { + * // Handle error. + * } + * + * console.log(logStream); + * }); + * @param {object} params Log Stream parameters. + * @param {string} params.id Log Stream ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getLogStream(...args) { + return this.logStreams.get(...args); + } -/** - * Get all users. - * - * @method getUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * search_engine: 'v3', - * per_page: 10, - * page: 0 - * }; - * - * auth0.getUsers(params, function (err, users) { - * console.log(users.length); - * }); - * - * @param {Object} [params] Users params. - * @param {Number} [params.search_engine] The version of the search engine to use. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getUsers', 'users.getAll'); + /** + * Delete an existing Log Stream. + * + * @example + * management.deleteLogStream({ id: LOG_STREAM_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Log Stream deleted. + * }); + * @param {object} params Log Stream parameters. + * @param {string} params.id Log Stream ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteLogStream(...args) { + return this.logStreams.delete(...args); + } -/** - * Get users for a given email address - * - * @method getUsersByEmail - * @memberOf module:management.ManagementClient.prototype - * - * @example <caption> - * This method takes an email address as the first argument, - * and returns all users with that email address - * </caption> - * - * auth0.getUsersByEmail(email, function (err, users) { - * console.log(users); - * }); - * - * @param {String} [email] Email Address of users to locate - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getUsersByEmail', 'users.getByEmail'); + /** + * Update an existing Log Stream. + * + * @example + * var params = { id: LOG_STREAM_ID }; + * var data = { name: 'my-log-stream'}; + * management.updateLogStream(params, data, function (err, logStream) { + * if (err) { + * // Handle error. + * } + * + * console.log(logStream.name); // 'my-log-stream'. + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {object} data Updated rule data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateLogStream(...args) { + return this.logStreams.update(...args); + } -/** - * Get a user by its id. - * - * @method getUser - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getUser({ id: USER_ID }, function (err, user) { - * console.log(user); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getUser', 'users.get'); + /** + * Create a new resource server. + * + * @example + * management.createResourceServer(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Resource Server created. + * }); + * @param {object} data Resource Server data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createResourceServer(...args) { + return this.resourceServers.create(...args); + } -/** - * Delete all users. - * - * @method deleteAllUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteAllUsers(function (err) { - * if (err) { - * // Handle error. - * } - * - * // Users deleted - * }); - * - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - * - * @deprecated This method will be removed in the next major release. - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteAllUsers', 'users.deleteAll'); + /** + * Get all resource servers. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getResourceServers(params, function (err, resourceServers) { + * console.log(resourceServers.length); + * }); + * @param {object} [params] Resource Servers parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getResourceServers(...args) { + return this.resourceServers.getAll(...args); + } -/** - * Delete a user by its id. - * - * @method deleteUser - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteUser({ id: USER_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // User deleted. - * }); - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteUser', 'users.delete'); + /** + * Get a Resource Server. + * + * @example + * management.getResourceServer({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) { + * if (err) { + * // Handle error. + * } + * + * console.log(resourceServer); + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getResourceServer(...args) { + return this.resourceServers.get(...args); + } -/** - * Create a new user. - * - * @method createUser - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createUser(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // User created. - * }); - * - * @param {Object} data User data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createUser', 'users.create'); + /** + * Delete an existing resource server. + * + * @example + * management.deleteResourceServer({ id: RESOURCE_SERVER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Resource Server deleted. + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteResourceServer(...args) { + return this.resourceServers.delete(...args); + } -/** - * Update a user by its id. - * - * @method updateUser - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID }; - * - * management.updateUser(params, data, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user parameters. - * @param {String} params.id The user id. - * @param {Object} data New user data. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateUser', 'users.update'); + /** + * Update an existing resource server. + * + * @example + * var data = { name: 'newResourceServerName' }; + * var params = { id: RESOURCE_SERVER_ID }; + * + * management.updateResourceServer(params, data, function (err, resourceServer) { + * if (err) { + * // Handle error. + * } + * + * console.log(resourceServer.name); // 'newResourceServerName' + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {object} data Updated Resource Server data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateResourceServer(...args) { + return this.resourceServers.update(...args); + } -/** - * Update the user metadata for a user. - * - * @method updateUserMetadata - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID }; - * var metadata = { - * address: '123th Node.js Street' - * }; - * - * management.updateUserMetadata(params, metadata, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Object} metadata New user metadata. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateUserMetadata', 'users.updateUserMetadata'); + /** + * Set a new rules config. + * + * @example + * var params = { key: RULE_CONFIG_KEY }; + * var data = { value: RULES_CONFIG_VALUE }; + * + * management.setRulesConfig(params, data, function (err, rulesConfig) { + * if (err) { + * // Handle error. + * } + * + * // Rules Config set. + * }); + * @param {object} params Rule Config parameters. + * @param {string} params.key Rule Config key. + * @param {object} data Rule Config Data parameters. + * @param {string} data.value Rule Config Data value. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + setRulesConfig(...args) { + return this.rulesConfigs.set(...args); + } -/** - * Update the app metadata for a user. - * - * @method updateAppMetadata - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID }; - * var metadata = { - * foo: 'bar' - * }; - * - * management.updateAppMetadata(params, metadata, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Object} metadata New app metadata. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateAppMetadata', 'users.updateAppMetadata'); + /** + * Get rules config. + * + * @param {Function} [cb] Callback function. + * @example + * + * management.getRulesConfigs(function (err, rulesConfigs) { + * if (err) { + * // Handle error. + * } + * + * // Get Rules Configs. + * }); + * @returns {Promise|undefined} + */ + getRulesConfigs(...args) { + return this.rulesConfigs.getAll(...args); + } -/** - * Delete a multifactor provider for a user. - * - * @method deleteUserMultifactor - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; - * - * management.deleteUserMultifactor(params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users accounts unlinked. - * }); - * - * @param {Object} params Data object. - * @param {String} params.id The user id. - * @param {String} params.provider Multifactor provider. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'deleteUserMultifactor', - 'users.deleteMultifactorProvider' -); + /** + * Delete rules config. + * + * @example + * + * management.deleteRulesConfig({ key: RULE_CONFIG_KEY }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Rules Config deleted. + * }); + * @param {object} params Rule Configs parameters. + * @param {string} params.key Rule Configs key. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteRulesConfig(...args) { + return this.rulesConfigs.delete(...args); + } -/** - * Delete a multifactor provider for a user. - * - * @method deleteUserMultifcator - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; - * - * management.deleteUserMultifcator(params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users accounts unlinked. - * }); - * - * @param {Object} params Data object. - * @param {String} params.id The user id. - * @param {String} params.provider Multifactor provider. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - * - * @deprecated The function name has a typo. - * We're shipping this so it doesn't break compatibility. - * Use {@link deleteUserMultifactor} instead. - */ -utils.wrapPropertyMethod( - ManagementClient, - 'deleteUserMultifcator', - 'users.deleteMultifactorProvider' -); + /** + * Create an Auth0 Custom Domain. + * + * @example + * management.createCustomDomain(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // CustomDomain created. + * }); + * @param {object} data The custom domain data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createCustomDomain(...args) { + return this.customDomains.create(...args); + } -/** - * Unlink the given accounts. - * - * @method unlinkUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID }; - * - * management.unlinkUsers(params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users accounts unlinked. - * }); - * - * @param {Object} params Linked users data. - * @param {String} params.id Primary user ID. - * @param {String} params.provider Identity provider in use. - * @param {String} params.user_id Secondary user ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'unlinkUsers', 'users.unlink'); + /** + * Get all Auth0 CustomDomains. + * + * @example + * management.getCustomDomains(function (err, customDomains) { + * console.log(customDomains.length); + * }); + * @returns {Promise|undefined} + */ + getCustomDomains(...args) { + return this.customDomains.getAll(...args); + } -/** - * Link the user with another account. - * - * @method linkUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var userId = 'USER_ID'; - * var params = { - * user_id: 'OTHER_USER_ID', - * connection_id: 'CONNECTION_ID' - * }; - * - * management.linkUsers(userId, params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users linked. - * }); - * - * @param {String} userId ID of the primary user. - * @param {Object} params Secondary user data. - * @param {String} params.user_id ID of the user to be linked. - * @param {String} params.connection_id ID of the connection to be used. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'linkUsers', 'users.link'); + /** + * Get a Custom Domain. + * + * @example + * management.getCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { + * if (err) { + * // Handle error. + * } + * + * console.log(customDomain); + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getCustomDomain(...args) { + return this.customDomains.get(...args); + } -/** - * Get user's log events. - * - * @method getUserLogs - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; - * - * management.getUserLogs(params, function (err, logs) { - * if (err) { - * // Handle error. - * } - * - * console.log(logs); - * }); - * - * @param {Object} params Get logs data. - * @param {String} params.id User id. - * @param {Number} params.per_page Number of results per page. - * @param {Number} params.page Page number, zero indexed. - * @param {String} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. - * @param {Boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getUserLogs', 'users.logs'); + /** + * Verify a Custom Domain. + * + * @example + * management.verifyCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { + * if (err) { + * // Handle error. + * } + * + * console.log(customDomain); + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + verifyCustomDomain(...args) { + return this.customDomains.verify(...args); + } -/** - * Get a list of a user's Guardian enrollments. - * - * @method getGuardianEnrollments - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) { - * console.log(enrollments); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'getGuardianEnrollments', - 'users.getGuardianEnrollments' -); + /** + * Delete a Custom Domain. + * + * @example + * management.deleteCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // CustomDomain deleted. + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteCustomDomain(...args) { + return this.customDomains.delete(...args); + } -/** - * Generate new Guardian recovery code. - * - * @method regenerateRecoveryCode - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.regenerateRecoveryCode({ id: USER_ID }, function (err, newRecoveryCode) { - * console.log(newRecoveryCode); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'regenerateRecoveryCode', - 'users.regenerateRecoveryCode' -); + /** + * Create a Guardian enrollment ticket. + * + * @example + * management.createGuardianEnrollmentTicket(function (err, ticket) { + * console.log(ticket); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createGuardianEnrollmentTicket(...args) { + return this.guardian.createEnrollmentTicket(...args); + } + + /** + * Get a list of Guardian factors and statuses. + * + * @example + * management.getGuardianFactors(function (err, factors) { + * console.log(factors.length); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianFactors(...args) { + return this.guardian.getFactors(...args); + } -/** - * Get a single Guardian enrollment. - * - * @method getGuardianEnrollment - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) { - * console.log(enrollment); - * }); - * - * @param {Object} data The Guardian enrollment data object. - * @param {String} data.id The Guardian enrollment id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'getGuardianEnrollment', - 'guardian.getGuardianEnrollment' -); + /** + * Get the settings of a Guardian factor. + * + * @example + * management.getGuardianFactorSettings({ name: 'duo' }, function (err, settings) { + * console.log(settings); + * }); + * @param {object} params Factor parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianFactorSettings(...args) { + return this.guardian.getFactorSettings(...args); + } -/** - * Delete a user's Guardian enrollment. - * - * @method deleteGuardianEnrollment - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email provider deleted. - * }); - * - * @param {Object} data The Guardian enrollment data object. - * @param {String} data.id The Guardian enrollment id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'deleteGuardianEnrollment', - 'guardian.deleteGuardianEnrollment' -); + /** + * Get Guardian factor provider configuration + * + * @example + * management.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) { + * console.log(provider); + * }); + * @param {object} params Factor provider parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianFactorProvider(...args) { + return this.guardian.getFactorProvider(...args); + } -/** - * Get all blacklisted tokens. - * - * @method getBlacklistedTokens - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getBlacklistedTokens(function (err, tokens) { - * console.log(tokens.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getBlacklistedTokens', 'blacklistedTokens.getAll'); + /** + * Update Guardian's factor provider + * + * @example + * management.updateGuardianFactorProvider({ name: 'sms', provider: 'twilio' }, { + * messaging_service_sid: 'XXXXXXXXXXXXXX', + * auth_token: 'XXXXXXXXXXXXXX', + * sid: 'XXXXXXXXXXXXXX' + * }, function (err, provider) { + * console.log(provider); + * }); + * @param {object} params Factor provider parameters. + * @param {object} data Updated Factor provider data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianFactorProvider(...args) { + return this.guardian.updateFactorProvider(...args); + } -/** - * Blacklist a new token. - * - * @method blacklistToken - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var token = { - * aud: 'aud', - * jti: 'jti' - * }; - * - * management.blacklistToken(token, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Token blacklisted. - * }); - * - * @param {Object} token Token data. - * @param {String} token.aud Audience (your app client ID). - * @param {String} token.jti The JWT ID claim. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'blacklistToken', 'blacklistedTokens.add'); + /** + * Update a Guardian's factor settings + * + * @example + * management.updateGuardianFactorSettings( + * { name: 'webauthn-roaming' }, + * { userVerification: 'discouraged', overrideRelyingParty: false }, + * function (err, settings) { + * console.log(settings); + * }) + * @param {object} params Factor parameters. + * @param {object} data Updated Factor settings data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianFactorSettings(...args) { + return this.guardian.updateFactorSettings(...args); + } -/** - * Get the email provider. - * - * @method getEmailProvider - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getEmailProvider(function (err, provider) { - * console.log(provider.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getEmailProvider', 'emailProvider.get'); + /** + * Get Guardian enrollment and verification factor templates + * + * @example + * management.getGuardianFactorTemplates({ name: 'sms' }, function (err, templates) { + * console.log(templates); + * }); + * @param {object} params Factor parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianFactorTemplates(...args) { + return this.guardian.getFactorTemplates(...args); + } -/** - * Configure the email provider. - * - * @method configureEmailProvider - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.configureEmailProvider(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email provider configured. - * }); - * - * @param {Object} data The email provider data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'configureEmailProvider', 'emailProvider.configure'); + /** + * Update Guardian enrollment and verification factor templates + * + * @example + * management.updateGuardianFactorTemplates({ name: 'sms' }, { + * enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.", + * verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}" + * }, function (err, templates) { + * console.log(templates); + * }); + * @param {object} params Factor parameters. + * @param {object} data Updated factor templates data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianFactorTemplates(...args) { + return this.guardian.updateFactorTemplates(...args); + } -/** - * Delete email provider. - * - * @method deleteEmailProvider - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteEmailProvider(function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email provider deleted. - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteEmailProvider', 'emailProvider.delete'); + /** + * Update Guardian Factor + * + * @example + * management.updateGuardianFactor({ name: 'sms' }, { + * enabled: true + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Factor parameters. + * @param {object} data Updated factor data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianFactor(...args) { + return this.guardian.updateFactor(...args); + } -/** - * Update the email provider. - * - * @method updateEmailProvider - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.updateEmailProvider(params, data, function (err, provider) { - * if (err) { - * // Handle error. - * } - * - * // Updated email provider. - * console.log(provider); - * }); - * - * @param {Object} params Email provider parameters. - * @param {Object} data Updated email provider data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateEmailProvider', 'emailProvider.update'); + /** + * Get enabled Guardian policies + * + * @example + * management.getGuardianPolicies(function (err, policies) { + * console.log(policies); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianPolicies(...args) { + return this.guardian.getPolicies(...args); + } -/** - * Get a the active users count. - * - * @method getActiveUsersCount - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getActiveUsersCount(function (err, usersCount) { - * if (err) { - * // Handle error. - * } - * - * console.log(usersCount); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getActiveUsersCount', 'stats.getActiveUsersCount'); + /** + * Update enabled Guardian policies + * + * @example + * management.updateGuardianPolicies({}, [ + * 'all-applications' + * ], function (err, policies) { + * console.log(policies); + * }); + * @param {object} params Parameters. + * @param {string[]} data Policies to enable. Empty array disables all policies. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianPolicies(...args) { + return this.guardian.updatePolicies(...args); + } -/** - * Get the daily stats. - * - * @method getDailyStats - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * from: '{YYYYMMDD}', // First day included in the stats. - * to: '{YYYYMMDD}' // Last day included in the stats. - * }; - * - * management.getDaily(params, function (err, stats) { - * if (err) { - * // Handle error. - * } - * - * console.log(stats); - * }); - * - * @param {Object} params Stats parameters. - * @param {String} params.from The first day in YYYYMMDD format. - * @param {String} params.to The last day in YYYYMMDD format. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getDailyStats', 'stats.getDaily'); + /** + * Get the Guardian phone factor's selected provider + * + * @example + * management.getGuardianPhoneFactorSelectedProvider(function (err, selectedProvider) { + * console.log(selectedProvider); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianPhoneFactorSelectedProvider(...args) { + return this.guardian.getPhoneFactorSelectedProvider(...args); + } -/** - * Get the tenant settings.. - * - * @method getTenantSettings - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getSettings(function (err, settings) { - * if (err) { - * // Handle error. - * } - * - * console.log(settings); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getTenantSettings', 'tenant.getSettings'); + /** + * Update the Guardian phone factor's selected provider + * + * @example + * management.updateGuardianPhoneFactorSelectedProvider({}, { + * provider: 'twilio' + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Parameters. + * @param {object} data Updated selected provider data. + * @param {string} data.provider Name of the selected provider + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianPhoneFactorSelectedProvider(...args) { + return this.guardian.updatePhoneFactorSelectedProvider(...args); + } -/** - * Update the tenant settings. - * - * @method updateTenantSettings - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.updateTenantSettings(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data The new tenant settings. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateTenantSettings', 'tenant.updateSettings'); + /** + * Get the Guardian phone factor's message types + * + * @example + * management.getGuardianPhoneFactorMessageTypes(function (err, messageTypes) { + * console.log(messageTypes); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianPhoneFactorMessageTypes(...args) { + return this.guardian.getPhoneFactorMessageTypes(...args); + } -/** - * Get a job by its ID. - * - * @method getJob - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * id: '{JOB_ID}' - * }; - * - * management.getJob(params, function (err, job) { - * if (err) { - * // Handle error. - * } - * - * // Retrieved job. - * console.log(job); - * }); - * - * @param {Object} params Job parameters. - * @param {String} params.id Job ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getJob', 'jobs.get'); + /** + * Update the Guardian phone factor's message types + * + * @example + * management.updateGuardianPhoneFactorMessageTypes({}, { + * message_types: ['sms', 'voice'] + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Parameters. + * @param {object} data Updated selected provider data. + * @param {string[]} data.message_types Message types (only `"sms"` and `"voice"` are supported). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianPhoneFactorMessageTypes(...args) { + return this.guardian.updatePhoneFactorMessageTypes(...args); + } -/** - * Given a path to a file and a connection id, create a new job that imports the - * users contained in the file and associate them with the given connection. - * - * @method importUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * connection_id: '{CONNECTION_ID}', - * users: '{PATH_TO_USERS_FILE}' - * }; - * - * management.get(params, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data Users import data. - * @param {String} data.connectionId Connection for the users insertion. - * @param {String} data.users Path to the users data file. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'importUsers', 'jobs.importUsers'); + /** + * Get all roles. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getRoles(params, function (err, roles) { + * console.log(roles.length); + * }); + * @param {object} [params] Roles parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRoles(...args) { + return this.roles.getAll(...args); + } -/** - * Send a verification email to a user. - * - * @method sendEmailVerification - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * user_id: '{USER_ID}' - * }; - * - * management.sendEmailVerification(function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data User data object. - * @param {String} data.user_id ID of the user to be verified. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'sendEmailVerification', 'jobs.verifyEmail'); + /** + * Create a new role. + * + * @example + * data = {"name": "test1","description": "123"} + * management.createRole(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Role created. + * }); + * @param {object} data Role data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createRole(...args) { + return this.roles.create(...args); + } -/** - * Create a new password change ticket. - * - * @method createPasswordChangeTicket - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * result_url: '{REDIRECT_URL}', // Redirect after using the ticket. - * user_id: '{USER_ID}', // Optional. - * email: '{USER_EMAIL}', // Optional. - * new_password: '{PASSWORD}' - * }; - * - * auth0.createPasswordChangeTicket(params, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Function} [cb] Callback function. - * @return {Promise} - */ -utils.wrapPropertyMethod(ManagementClient, 'createPasswordChangeTicket', 'tickets.changePassword'); + /** + * Get an Auth0 role. + * + * @example + * management.getRole({ id: ROLE_ID }, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(role); + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRole(...args) { + return this.roles.get(...args); + } -/** - * Create an email verification ticket. - * - * @method createEmailVerificationTicket - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var data = { - * user_id: '{USER_ID}', - * result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used. - * }; - * - * auth0.createEmailVerificationTicket(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Function} [cb] Callback function. - * @return {Promise} - */ -utils.wrapPropertyMethod(ManagementClient, 'createEmailVerificationTicket', 'tickets.verifyEmail'); + /** + * Delete an existing role. + * + * @example + * management.deleteRole({ id: ROLE_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Role deleted. + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteRole(...args) { + return this.roles.delete(...args); + } -/** - * Get an Auth0 log. - * - * @method getLog - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getLog({ id: EVENT_ID }, function (err, log) { - * if (err) { - * // Handle error. - * } - * - * console.log(log); - * }); - * - * @param {Object} params Log parameters. - * @param {String} params.id Event ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getLog', 'logs.get'); + /** + * Update an existing role. + * + * @example + * var params = { id: ROLE_ID }; + * var data = { name: 'my-role'}; + * management.updateRole(params, data, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(role.name); // 'my-role'. + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {object} data Updated role data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateRole(...args) { + return this.roles.update(...args); + } -/** - * Get all logs. - * - * @method getLogs - * @memberOf module:management.ManagementClient.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings and the search query. If pagination options are - * not present, the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 2 - * }; - * - * management.getLogs(params, function (err, logs) { - * console.log(logs.length); - * }); - * - * @param {Object} [params] Logs params. - * @param {String} [params.q] Search Criteria using Query String Syntax - * @param {Number} [params.page] Page number. Zero based - * @param {Number} [params.per_page] The amount of entries per page - * @param {String} [params.sort] The field to use for sorting. - * @param {String} [params.fields] A comma separated list of fields to include or exclude - * @param {Boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise. - * @param {Boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getLogs', 'logs.getAll'); + /** + * Get permissions for a given role + * + * @example + * var params = { id :'ROLE_ID'}; + * @example <caption> + * This method takes a roleId and + * returns all permissions within that role + * + * </caption> + * + * management.getPermissionsInRole(params, function (err, permissions) { + * console.log(permissions); + * }); + * @param {string} [roleId] Id of the role + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPermissionsInRole(...args) { + return this.roles.getPermissions(...args); + } -/** - * Create a new resource server. - * - * @method createResourceServer - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createResourceServer(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Resource Server created. - * }); - * - * @param {Object} data Resource Server data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createResourceServer', 'resourceServers.create'); + /** + * Add permissions in a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.addPermissionsInRole(params, data, function (err, permissions) { + * console.log(permissions); + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + addPermissionsInRole(...args) { + return this.roles.addPermissions(...args); + } + + /** + * Remove permissions from a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.removePermissionsFromRole(params, data, function (err, permissions) { + * console.log(permissions); + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removePermissionsFromRole(...args) { + return this.roles.removePermissions(...args); + } + + /** + * Get users in a given role + * + * @example + * var params = { + * id: 'ROLE_ID', + * per_page: 50, + * page: 0 + * }; + * @example <caption> + * This method takes a roleId and returns all users within that role. Supports offset (page, per_page) and checkpoint pagination (from, take). You must use checkpoint pagination to retrieve beyond the first 1000 records. + * </caption> + * + * management.getUsersInRole(params, function (err, users) { + * console.log(users); + * }); + * @param {string} [id] Id of the role + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {string} [params.from] Optional id from which to start selection. + * @param {number} [params.take] The total amount of entries to retrieve when using the from parameter. Defaults to 50. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUsersInRole(...args) { + return this.roles.getUsers(...args); + } -/** - * Get all resource servers. - * - * @method getResourceServers - * @memberOf module:management.ManagementClient.prototype - * - * @example <caption> - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * </caption> - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getResourceServers(params, function (err, resourceServers) { - * console.log(resourceServers.length); - * }); - * - * @param {Object} [params] Resource Servers parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getResourceServers', 'resourceServers.getAll'); + /** + * Get all hooks. + * + * @example <caption> + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * </caption> + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getHooks(params, function (err, hooks) { + * console.log(hooks.length); + * }); + * @param {object} [params] Hooks parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getHooks(...args) { + return this.hooks.getAll(...args); + } -/** - * Get a Resource Server. - * - * @method getResourceServer - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getResourceServer({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) { - * if (err) { - * // Handle error. - * } - * - * console.log(resourceServer); - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getResourceServer', 'resourceServers.get'); + /** + * Get an Auth0 hook. + * + * @example + * management.getHook({ id: HOOK_ID }, function (err, hook) { + * if (err) { + * // Handle error. + * } + * + * console.log(hook); + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getHook(...args) { + return this.hooks.get(...args); + } -/** - * Delete an existing resource server. - * - * @method deleteResourceServer - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteResourceServer({ id: RESOURCE_SERVER_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Resource Server deleted. - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteResourceServer', 'resourceServers.delete'); + /** + * Create a new hook. + * + * @example + * management.createHook(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Hook created. + * }); + * @param {object} data Hook data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createHook(...args) { + return this.hooks.create(...args); + } -/** - * Update an existing resource server. - * - * @method updateResourceServer - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var data = { name: 'newResourceServerName' }; - * var params = { id: RESOURCE_SERVER_ID }; - * - * management.updateResourceServer(params, data, function (err, resourceServer) { - * if (err) { - * // Handle error. - * } - * - * console.log(resourceServer.name); // 'newResourceServerName' - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Object} data Updated Resource Server data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateResourceServer', 'resourceServers.update'); + /** + * Update an existing hook. + * + * @example + * var params = { id: HOOK_ID }; + * var data = { name: 'my-hook'}; + * management.updateHook(params, data, function (err, hook) { + * if (err) { + * // Handle error. + * } + * + * console.log(hook.name); // 'my-hook'. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Updated hook data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateHook(...args) { + return this.hooks.update(...args); + } -/** - * Set a new rules config. - * - * @method setRulesConfig - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { key: RULE_CONFIG_KEY }; - * var data = { value: RULES_CONFIG_VALUE }; - * - * management.setRulesConfig(params, data, function (err, rulesConfig) { - * if (err) { - * // Handle error. - * } - * - * // Rules Config set. - * }); - * - * @param {Object} params Rule Config parameters. - * @param {String} params.key Rule Config key. - * @param {Object} data Rule Config Data parameters. - * @param {String} data.value Rule Config Data value. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'setRulesConfig', 'rulesConfigs.set'); + /** + * Delete an existing hook. + * + * @example + * auth0.deleteHook({ id: HOOK_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Hook deleted. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteHook(...args) { + return this.hooks.delete(...args); + } -/** - * Get rules config. - * - * @method getRulesConfigs - * @memberOf module:management.ManagementClient.prototype - * - * @example - * - * management.getRulesConfigs(function (err, rulesConfigs) { - * if (err) { - * // Handle error. - * } - * - * // Get Rules Configs. - * }); - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getRulesConfigs', 'rulesConfigs.getAll'); + /** + * Get an Auth0 hook's secrets. + * + * @example + * var params = { id: HOOK_ID } + * management.getHookSecrets(params, function (err, secrets) { + * if (err) { + * // Handle error. + * } + * + * console.log(secrets); + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getHookSecrets(...args) { + return this.hooks.getSecrets(...args); + } -/** - * Delete rules config. - * - * @method deleteRulesConfig - * @memberOf module:management.ManagementClient.prototype - * - * @example - * - * management.deleteRulesConfig({ key: RULE_CONFIG_KEY }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rules Config deleted. - * }); - * - * @param {Object} params Rule Configs parameters. - * @param {String} params.key Rule Configs key. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteRulesConfig', 'rulesConfigs.delete'); + /** + * Add hook screts. + * + * @example + * var params = { id: 'HOOK_ID' } + * var data = { DB_PASSWORD: 'password1', API_TOKEN: 'secret' } + * management.addHookScrets(params, data, function (err, secrets) { + * if (err) { + * // Handle error. + * } + * + * // Hook secrets created. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Secrets key/value pairs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + addHookSecrets(...args) { + return this.hooks.addSecrets(...args); + } -/** - * Create an Auth0 Custom Domain. - * - * @method create - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.createCustomDomain(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // CustomDomain created. - * }); - * - * @param {Object} data The custom domain data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createCustomDomain', 'customDomains.create'); + /** + * Update an existing hook. + * + * @example + * var params = { id: HOOK_ID }; + * var data = { API_TOKEN: 'updated-secret'}; + * management.updateHookSecrets(params, data, function (err, secrets) { + * if (err) { + * // Handle error. + * } + * + * console.log(secrets) + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Secrets key/value pairs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateHookSecrets(...args) { + return this.hooks.updateSecrets(...args); + } -/** - * Get all Auth0 CustomDomains. - * - * @method getAll - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.getCustomDomains(function (err, customDomains) { - * console.log(customDomains.length); - * }); - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getCustomDomains', 'customDomains.getAll'); + /** + * Delete an existing hook. + * + * @example + * var params = { id: HOOK_ID } + * var data = ['API_TOKEN', 'DB_PASSWORD'] + * auth0.removeHookSecrets(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Hook deleted. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Secrets key/value pairs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removeHookSecrets(...args) { + return this.hooks.removeSecrets(...args); + } -/** - * Get a Custom Domain. - * - * @method get - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.getCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { - * if (err) { - * // Handle error. - * } - * - * console.log(customDomain); - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getCustomDomain', 'customDomains.get'); + /** + * Returns the access_token. + * + * @returns {Promise} Promise returning an access_token. + */ + getAccessToken(...args) { + return this.tokenProvider.getAccessToken(...args); + } -/** - * Verify a Custom Domain. - * - * @method verify - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.verifyCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { - * if (err) { - * // Handle error. - * } - * - * console.log(customDomain); - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'verifyCustomDomain', 'customDomains.verify'); + /** + * Update the branding settings. + * + * @example + * management.updateBrandingSettings(data, function (err, branding) { + * if (err) { + * // Handle error. + * } + * + * // Updated branding + * console.log(branding); + * }); + * @param {object} params Branding parameters. + * @param {object} data Updated branding data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateBrandingSettings(...args) { + return this.branding.updateSettings(...args); + } -/** - * Delete a Custom Domain. - * - * @method delete - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.deleteCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // CustomDomain deleted. - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteCustomDomain', 'customDomains.delete'); + /** + * Get the branding settings.. + * + * @example + * management.getBrandingSettings(data, function (err, branding) { + * if (err) { + * // Handle error. + * } + * + * // Branding + * console.log(branding); + * }); + * @param {object} params Branding parameters. + * @param {object} data Branding data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getBrandingSettings(...args) { + return this.branding.getSettings(...args); + } -/** - * Create a Guardian enrollment ticket. - * - * @method createGuardianEnrollmentTicket - * @memberOf module:management.GuardianManager.prototype - * - * @example - * management.createGuardianEnrollmentTicket(function (err, ticket) { - * console.log(ticket); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'createGuardianEnrollmentTicket', - 'guardian.tickets.create' -); + /** + * Get the new universal login template. + * + * @example + * management.getBrandingUniversalLoginTemplate(data, function (err, template) { + * if (err) { + * // Handle error. + * } + * + * // Branding + * console.log(template); + * }); + * @param {object} params Branding parameters (leave empty). + * @param {object} data Branding data (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getBrandingUniversalLoginTemplate(...args) { + return this.branding.getUniversalLoginTemplate(...args); + } -/** - * Get a list of Guardian factors and statuses. - * - * @method getGuardianFactors - * @memberOf module:management.GuardianManager.prototype - * - * management.getGuardianFactors(function (err, factors) { - * console.log(factors.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getGuardianFactors', 'guardian.factors.getAll'); + /** + * Set the new universal login template. + * + * @example + * management.setBrandingUniversalLoginTemplate({}, { template: "a template" }, function (err, template) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Branding parameters (leave empty). + * @param {object} template Branding data (object with template field). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + setBrandingUniversalLoginTemplate(...args) { + return this.branding.setUniversalLoginTemplate(...args); + } -/** - * Get Guardian factor provider configuration - * - * @method getGuardianFactorProvider - * @memberOf module:management.GuardianManager.prototype - * - * management.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) { - * console.log(provider); - * }); - * - * @param {Object} params Factor provider parameters. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'getGuardianFactorProvider', - 'guardian.factorsProviders.get' -); + /** + * Delete the new universal login template. + * + * @example + * management.deleteBrandingUniversalLoginTemplate(template, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Branding parameters (leave empty). + * @param {object} data Branding data (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteBrandingUniversalLoginTemplate(...args) { + return this.branding.deleteUniversalLoginTemplate(...args); + } -/** - * Update Guardian's factor provider - * - * @method updateFactorProvider - * @memberOf module:management.GuardianManager.prototype - * - * management.updateGuardianFactorProvider({ name: 'sms', provider: 'twilio' }, { - * messaging_service_sid: 'XXXXXXXXXXXXXX', - * auth_token: 'XXXXXXXXXXXXXX', - * sid: 'XXXXXXXXXXXXXX' - * }, function(err, provider) { - * console.log(provider); - * }); - * - * @param {Object} params Factor provider parameters. - * @param {Object} data Updated Factor provider data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'updateGuardianFactorProvider', - 'guardian.factorsProviders.update' -); + /** + * Update the tenant migrations. + * + * @example + * data = { flags: { migration: true } }; + * management.updateMigrations(data, function (err, migrations) { + * if (err) { + * // Handle error. + * } + * + * // Updated migrations flags + * console.log(migrations.flags); + * }); + * @param {object} data Updated migrations data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateMigrations(...args) { + return this.migrations.updateMigrations(...args); + } -/** - * Get Guardian enrollment and verification factor templates - * - * @method getGuardianFactorTemplates - * @memberOf module:management.GuardianManager.prototype - * - * management.getGuardianFactorTemplates({ name: 'sms' }, function (err, templates) { - * console.log(templates); - * }); - * - * @param {Object} params Factor parameters. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'getGuardianFactorTemplates', - 'guardian.factorsTemplates.get' -); + /** + * Get migrations flags + * + * @example + * management.getMigrations(function (err, migrations) { + * if (err) { + * // Handle error. + * } + * + * // Migration flags + * console.log(migrations.flags); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getMigrations(...args) { + return this.migrations.getMigrations(...args); + } -/** - * Update Guardian enrollment and verification factor templates - * - * @method updateGuardianFactorTemplates - * @memberOf module:management.GuardianManager.prototype - * - * management.updateGuardianFactorTemplates({ name: 'sms' }, { - * enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.", - * verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}" - * }, function(err, templates) { - * console.log(templates); - * }); - * - * @param {Object} params Factor parameters. - * @param {Object} data Updated factor templates data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'updateGuardianFactorTemplates', - 'guardian.factorsTemplates.update' -); + /** + * Get prompts settings.. + * + * @example + * management.getPromptsSettings(function (err, settings) { + * console.log(settings); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPromptsSettings(...args) { + return this.prompts.getSettings(...args); + } -/** - * Update Guardian Factor - * - * @method updateGuardianFactor - * @memberOf module.GuardianManager.prototype - * - * management.updateGuardianFactor({ name: 'sms' }, { - * enabled: true - * }, function(err, factor) { - * console.log(factor); - * }); - * - * @param {Object} params Factor parameters. - * @param {Object} data Updated factor data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateGuardianFactor', 'guardian.factors.update'); + /** + * Update prompts settings. + * + * @example + * management.updatePromptsSettings(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data The new prompts settings. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updatePromptsSettings(...args) { + return this.prompts.updateSettings(...args); + } + /** + * Retrieve custom text for a specific prompt and language. + * + * @example + * var params = { prompt: PROMPT_NAME, language: LANGUAGE }; + * + * management.prompts.getCustomTextByLanguage(params, function (err, customText) { + * console.log('CustomText', customText); + * }); + * @param {object} params Data object. + * @param {string} params.prompt Name of the prompt. + * @param {string} params.language Language to retrieve. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + getCustomTextByLanguage(...args) { + return this.prompts.getCustomTextByLanguage(...args); + } + + /** + * Set custom text for a specific prompt. + * + * @example + * var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT }; + * + * management.prompts.updateCustomTextByLanguage(params, function (err, customText) { + * console.log('CustomText', customText); + * }); + * @param {object} params Data object. + * @param {string} params.prompt Name of the prompt. + * @param {string} params.language Language to retrieve. + * @param {object} params.body An object containing custom dictionaries for a group of screens. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateCustomTextByLanguage(...args) { + return this.prompts.updateCustomTextByLanguage(...args); + } +} module.exports = ManagementClient;
@@ -2248,7 +3432,7 @@

management/index.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/docs/module-auth.AuthenticationClient.html b/docs/module-auth.AuthenticationClient.html deleted file mode 100644 index fb612176b..000000000 --- a/docs/module-auth.AuthenticationClient.html +++ /dev/null @@ -1,3903 +0,0 @@ - - - - - - AuthenticationClient - Documentation - - - - - - - - - - - - - - - - - -
- -

AuthenticationClient

- - - - - - - -
- -
- -

- auth. - - AuthenticationClient -

- -

Authentication API SDK.

-

This client must used to access Auth0's -Authentication API.

- - -
- -
-
- - -
- - -

Constructor

- - -

new AuthenticationClient(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

Options for the Authentication Client SDK.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
domain - - -String - - - - - - - - - - -

AuthenticationClient server domain.

- -
clientId - - -String - - - - - - <optional>
- - - - - -
-

Default client ID.

- -
clientSecret - - -String - - - - - - <optional>
- - - - - -
-

Default client Secret.

- -
supportedAlgorithms - - -String - - - - - - <optional>
- - - - - -
-

Algorithms that your application expects to receive

- -
- - -
- - - - - - - - - - - - - - - - -
-
Example
- -

- The AuthenticationClient constructor takes an optional client - ID, if specified it will be used as default value for all endpoints that - accept a client ID. -

- -
var AuthenticationClient = require('auth0').AuthenticationClient;
-var auth0 = new AuthenticationClient({
-  domain: '{YOUR_ACCOUNT}.auth0.com',
-  clientId: '{OPTIONAL_CLIENT_ID}'
-});
- -
- -
- -
- - - - - - - - - - - - -

Members

- - - -
-

database :DatabaseAuthenticator

- - - - -
-

Database authenticator.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -DatabaseAuthenticator - - -
  • -
- - - - - -
- - - -
-

oauth :OAuthAuthenticator

- - - - -
-

OAuth authenticator.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -OAuthAuthenticator - - -
  • -
- - - - - -
- - - -
-

passwordless :PasswordlessAuthenticator

- - - - -
-

Passwordless authenticator.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -PasswordlessAuthenticator - - -
  • -
- - - - - -
- - - -
-

tokens :TokensManager

- - - - -
-

Tokens manager.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -TokensManager - - -
  • -
- - - - - -
- - - -
-

users :UsersManager

- - - - -
-

Users manager.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -UsersManager - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

changePassword(data) → {Promise|undefined}

- - - - - -
-

Change password using a database or active directory service.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

User data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
email - - -String - - - - -

User email.

- -
password - - -String - - - - -

User password.

- -
connection - - -String - - - - -

Identity provider for the user.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user email, the connection specified and the new password to - use, Auth0 will send a forgot password email. Once the user clicks on the - confirm password change link, the new password specified in this POST will - be set to this user. Find more information in the - - API Docs. -

- -
var data = {
-  email: '{EMAIL}',
-  password: '{PASSWORD}',
-  connection: 'Username-Password-Authentication'
-};
-
-auth0.changePassword(data, function (err, message) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(message);
-});
- -
- -
- - -
- - - -

clientCredentialsGrant(options) → {Promise|undefined}

- - - - - -
-

Gets an access token using the client credentials grant flow.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
scope - - -String - - - - - - <optional>
- - - - - -
-

scopes to request to be added to the returned access token

- -
audience - - -String - - - - - - <optional>
- - - - - -
-

audience or identifier of the API where the access token will be used, e.g. Auth0 Management API

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Gets an access token using the client credentials grant flow. Find more information in the - API Docs. -

- -
auth0.clientCredentialsGrant({
-  audience: 'https://tenant.auth0.com/api/v2/',
-  scope: 'read:users update:users'
-}, function (err, response) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(response);
-});
- -
- -
- - -
- - - -

getClientInfo() → {Object}

- - - - - -
-

Return an object with information about the current client,

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Object - - -
-
- - -
-

Object containing client information.

-
- - -
- - - -
- - -
- - - -

getDelegationToken(data) → {Promise|undefined}

- - - - - -
-

Exchange the token of the logged in user with a token that is valid to call -the API (signed with the API secret).

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

Token data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id_token - - -String - - - - -

The user ID token.

- -
api_type - - -String - - - - -

The API type (aws, firebase, etc).

- -
target - - -String - - - - -

The target client ID.

- -
grant_type - - -String - - - - -

The grant type.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given an existing token, this endpoint will generate a new token signed - with the target client secret. This is used to flow the identity of the - user from the application to an API or across different APIs that are - protected with different secrets. Find more information in the - API Docs. -

- -
var data = {
-  id_token: '{ID_TOKEN}',
-  api_type: 'app',
-  target: '{TARGET}',
-  grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer'
-};
-
-auth0.getDelegationToken(data, function (err, token) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(token);
-});
- -
- -
- - -
- - - -

getProfile(accessToken) → {Promise|undefined}

- - - - - -
-

Given an access token get the user profile linked to it.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
accessToken - - -String - - - - -

The user access token.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Get the user information based on the Auth0 access token (obtained during - login). Find more information in the - API Docs. -

- -
auth0.getProfile(data, function (err, userInfo) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userInfo);
-});
- -
- -
- - -
- - - -

passwordGrant(userData) → {Promise|undefined}

- - - - - -
-

Sign in using a username and password

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
userData - - -Object - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
username - - -String - - - - - - - - - - -

Username.

- -
password - - -String - - - - - - - - - - -

User password.

- -
realm - - -String - - - - - - <optional>
- - - - - -
-

Name of the realm to use to authenticate or the connection name

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user's credentials perform the OAuth password grant - or Password Realm grant if a realm is provided, - it will return a JSON with the access_token and id_token. - More information in the - - API Docs - . -

- -
var data = {
-  client_id: '{CLIENT_ID}',  // Optional field.
-  username: '{USERNAME}',
-  password: '{PASSWORD}'
-  realm: '{CONNECTION_NAME}', // Optional field.
-  scope: 'openid'  // Optional field.
-};
-
-auth0.oauth.token(data, function (err, userData) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userData);
-});
- -
- -
- - -
- - - -

refreshToken(userData) → {Promise|undefined}

- - - - - -
-

Sign in using a refresh token

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
userData - - -Object - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
refresh_token - - -String - - - - -

Refresh token.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given a refresh token from a previous authentication request, - it will return a JSON with the access_token and id_token. - More information in the - - API Docs - . -

- -
var data = {
-  client_id: '{CLIENT_ID}', // Optional field.
-  refresh_token: '{REFRESH_TOKEN}',
-};
-
-auth0.refreshToken(data, function (err, userData) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userData);
-});
- -
- -
- - -
- - - -

requestChangePasswordEmail(data) → {Promise|undefined}

- - - - - -
-

Request a change password email using a database or active directory service.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

User data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
email - - -String - - - - -

User email.

- -
connection - - -String - - - - -

Identity provider for the user.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user email, the connection specified, Auth0 will send a change - password email. once the user clicks on the confirm password change link, - the new password specified in this POST will be set to this user. Find more - information in the var data = { - email: '{EMAIL}', - connection: 'Username-Password-Authentication' -}; - -auth0.requestChangePasswordEmail(data, function (err, message) { - if (err) { - // Handle error. - } - - console.log(message); -});

- -
- -
- - -
- - - -

requestEmailCode(data) → {Promise|undefined}

- - - - - -
-

Start passwordless flow sending an email.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

User data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
email - - -String - - - - - - - - - - -

User email address.

- -
authParams - - -Object - - - - - - <optional>
- - - - - -
-

Authentication parameters.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user `email` address, it will send an email with a verification - code. You can then authenticate with this user using the `/oauth/ro` - endpoint using the email as username and the code as password. - - Find more information in the - API Docs -

- -
var data = {
-  email: '{EMAIL}',
-  authParams: {} // Optional auth params.
-};
-
-auth0.requestEmailCode(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-};
- -
- -
- - -
- - - - - - - - - -
-

Start passwordless flow sending an email.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

User data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
email - - -String - - - - - - - - - - -

User email address.

- -
authParams - - -Object - - - - - - <optional>
- - - - - -
-

Authentication parameters.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user `email` address, it will send an email with a link. You can - then authenticate with this user opening the link and he will be - automatically logged in to the application. Optionally, you can - append/override parameters to the link (like `scope`, `redirect_uri`, - `protocol`, `response_type`, etc.) using `authParams` object. - - Find more information in the - API Docs -

- -
var data = {
-  email: '{EMAIL}',
-  authParams: {} // Optional auth params.
-};
-
-auth0.requestMagicLink(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-};
- -
- -
- - -
- - - -

requestSMSCode(data) → {Promise|undefined}

- - - - - -
-

Start passwordless flow sending an SMS.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

User data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
phone_number - - -String - - - - -

The user phone number.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user `phone_number`, it will send a SMS message with a - verification code. You can then authenticate with this user using the - `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as - `password`: -

- -
var data = {
-  phone_number: '{PHONE}'
-};
-
-auth0.requestSMSCode(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-});
- -
- -
- - -
- - - -

verifySMSCode(data) → {Promise|undefined}

- - - - - -
-

Sign in with the given user credentials.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

Credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
username - - -String - - - - -

Phone number.

- -
password - - -String - - - - -

Verification code.

- -
target - - -String - - - - -

Target client ID.

- -
grant_type - - -String - - - - -

Grant type.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Examples
- -

- Given the user credentials (`phone_number` and `code`), it will do the - authentication on the provider and return a JSON with the `access_token` - and `id_token`. -

- -
var data = {
-  username: '{PHONE_NUMBER}',
-  password: '{VERIFICATION_CODE}'
-};
-
-auth0.verifySMSCode(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -

- The user data object has the following structure. -

- -
{
-  id_token: String,
-  access_token: String,
-  token_type: String
-}
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-auth.DatabaseAuthenticator.html b/docs/module-auth.DatabaseAuthenticator.html deleted file mode 100644 index b7b29e7b2..000000000 --- a/docs/module-auth.DatabaseAuthenticator.html +++ /dev/null @@ -1,1747 +0,0 @@ - - - - - - DatabaseAuthenticator - Documentation - - - - - - - - - - - - - - - - - -
- -

DatabaseAuthenticator

- - - - - - - -
- -
- -

- auth. - - DatabaseAuthenticator -

- -

Abstracts the sign-in, sign-up and change-password processes for Database & -Active Directory authentication services.

- - -
- -
-
- - -
- - -

Constructor

- - -

new DatabaseAuthenticator(options, oauth)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

Authenticator options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The auth0 account URL.

- -
clientId - - -String - - - - - - <optional>
- - - - - -
-

Default client ID.

- -
- - -
oauth - - -OAuthAuthenticator - - - - -

OAuthAuthenticator instance.

- -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instace.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

changePassword(data, cbopt) → {Promise|undefined}

- - - - - -
-

Change password using a database or active directory service.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
email - - -String - - - - -

User email address.

- -
password - - -String - - - - -

New password.

- -
connection - - -String - - - - -

Identity provider in use.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Method callback.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user email, the connection specified and the new password to - use, Auth0 will send a forgot password email. Once the user clicks on the - confirm password change link, the new password specified in this POST will - be set to this user. Find more information in the - var data = { - email: '{EMAIL}', - password: '{PASSWORD}', - connection: 'Username-Password-Authentication' -}; - -auth0.database.changePassword(data, function (err, message) { - if (err) { - // Handle error. - } - - console.log(message); -});

- -
- -
- - -
- - - -

requestChangePasswordEmail(data, cbopt) → {Promise|undefined}

- - - - - -
-

Request a change password email using a database or active directory service.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
email - - -String - - - - -

User email address.

- -
connection - - -String - - - - -

Identity provider in use.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Method callback.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user email, the connection specified, Auth0 will send a change - password email. once the user clicks on the confirm password change link, - the new password specified in this POST will be set to this user. Find more - information in the var data = { - email: '{EMAIL}', - connection: 'Username-Password-Authentication' -}; - -auth0.database.requestChangePasswordEmail(data, function (err, message) { - if (err) { - // Handle error. - } - - console.log(message); -});

- -
- -
- - -
- - - -

signIn(data, cbopt) → {Promise|undefined}

- - - - - -
-

Sign in using a database or active directory service.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
username - - -String - - - - -

Username.

- -
password - - -String - - - - -

User password.

- -
connection - - -String - - - - -

Identity provider in use.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Method callback.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user credentials and the connection specified, it will do the - authentication on the provider and return a JSON with the `access_token` - and `id_token`. Find more information about the structure of the data - object in the - API docs. -

- -
var data = {
-  username: '{USERNAME}',
-  password: '{PASSWORD}',
-  connection: 'Username-Password-Authentication' // Optional field.
-};
-
-auth0.database.signIn(data, function (err, userData) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userData);
-});
- -
- -
- - -
- - - -

signUp(data, cbopt) → {Promise|undefined}

- - - - - -
-

Sign up using a database or active directory service.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
email - - -String - - - - -

User email address.

- -
password - - -String - - - - -

User password.

- -
connection - - -Stinrg - - - - -

Identity provider in use.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Method callback.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user credentials, the connection specified and (optionally) the - client ID, it will create a new user. Find more information in the - - API Docs. -

- -
var data = {
-  email: '{EMAIL}',
-  password: '{PASSWORD}',
-  connection: 'Username-Password-Authentication' // Optional field.
-};
-
-auth0.database.signUp(data, function (err, userData) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userData);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-auth.OAUthWithIDTokenValidation.html b/docs/module-auth.OAUthWithIDTokenValidation.html deleted file mode 100644 index 8697b3777..000000000 --- a/docs/module-auth.OAUthWithIDTokenValidation.html +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - OAUthWithIDTokenValidation - Documentation - - - - - - - - - - - - - - - - - -
- -

OAUthWithIDTokenValidation

- - - - - - - -
- -
- -

- auth. - - OAUthWithIDTokenValidation -

- -

Abstracts the oauth.create method with additional id_token validation

- - -
- -
-
- - -
- - -

Constructor

- - -

new OAUthWithIDTokenValidation(oauth, options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
oauth - - -Object - - - - -

An instance of @type {OAuthAuthenticator}

- -
options - - -Object - - - - -

Authenticator options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
domain - - -String - - - - - - - - - - -

AuthenticationClient server domain

- -
clientId - - -String - - - - - - <optional>
- - - - - -
-

Default client ID.

- -
clientSecret - - -String - - - - - - <optional>
- - - - - -
-

Default client Secret.

- -
supportedAlgorithms - - -String - - - - - - <optional>
- - - - - -
-

Algorithms that your application expects to receive

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-auth.OAuthAuthenticator.html b/docs/module-auth.OAuthAuthenticator.html deleted file mode 100644 index 1a653544b..000000000 --- a/docs/module-auth.OAuthAuthenticator.html +++ /dev/null @@ -1,1805 +0,0 @@ - - - - - - OAuthAuthenticator - Documentation - - - - - - - - - - - - - - - - - -
- -

OAuthAuthenticator

- - - - - - - -
- -
- -

- auth. - - OAuthAuthenticator -

- -

Abstracts the sign-in, sign-up and change-password processes for Database & -Active Directory authentication services.

- - -
- -
-
- - -
- - -

Constructor

- - -

new OAuthAuthenticator(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

Authenticator options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The Auth0 account URL.

- -
domain - - -String - - - - - - - - - - -

AuthenticationClient server domain

- -
clientId - - -String - - - - - - <optional>
- - - - - -
-

Default client ID.

- -
clientSecret - - -String - - - - - - <optional>
- - - - - -
-

Default client Secret.

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instace.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

authorizationCodeGrant(data) → {Promise|undefined}

- - - - - -
-

Sign in using an authorization code

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

Authorization code payload

- -
userData.code - - -String - - - - -

Code in URL returned after authentication

- -
userData.redirect_uri - - -String - - - - -

The URL to which Auth0 will redirect the browser after authorization has been granted by the user.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the code returned in the URL params after the redirect - from successful authentication, exchange the code for auth0 - credentials. It will return JSON with the access_token and id_token. - More information in the - - API Docs - . -

- -
var data = {
-  code: '{CODE}',
-  redirect_uri: '{REDIRECT_URI}',
-  client_id: '{CLIENT_ID}',  // Optional field.
-  client_secret: '{CLIENT_SECRET}',  // Optional field.
-};
-
-auth0.oauth.authorizationCodeGrant(data, function (err, userData) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userData);
-});
- -
- -
- - -
- - - -

passwordGrant(userData) → {Promise|undefined}

- - - - - -
-

Sign in using a username and password

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
userData - - -Object - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
username - - -String - - - - - - - - - - -

Username.

- -
password - - -String - - - - - - - - - - -

User password.

- -
realm - - -String - - - - - - <optional>
- - - - - -
-

Name of the realm to use to authenticate or the connection name

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user's credentials perform the OAuth password grant - or Password Realm grant if a realm is provided, - it will return a JSON with the access_token and id_token. - More information in the - - API Docs - . -

- -
var data = {
-  client_id: '{CLIENT_ID}',  // Optional field.
-  username: '{USERNAME}',
-  password: '{PASSWORD}',
-  realm: '{CONNECTION_NAME}', // Optional field.
-  scope: 'openid'  // Optional field.
-};
-
-auth0.oauth.passwordGrant(data, function (err, userData) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userData);
-});
- -
- -
- - -
- - - -

refreshToken(userData) → {Promise|undefined}

- - - - - -
-

Sign in using a refresh token

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
userData - - -Object - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
refresh_token - - -String - - - - -

Refresh token.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given a refresh token from a previous authentication request - it will return a JSON with the access_token and id_token. - More information in the - - API Docs - . -

- -
var data = {
-  client_id: '{CLIENT_ID}', // Optional field.
-  refresh_token: '{REFRESH_TOKEN}',
-};
-
-auth0.oauth.refreshToken(data, function (err, userData) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userData);
-});
- -
- -
- - -
- - - -

signIn(userData) → {Promise|undefined}

- - - - - -
-

Sign in using a username and password.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
userData - - -Object - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
username - - -String - - - - -

Username.

- -
password - - -String - - - - -

User password.

- -
connection - - -String - - - - -

The identity provider in use.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user's credentials and the connection specified, it - will return a JSON with the access_token and id_token. - More information in the - - API Docs - . -

- -
var data = {
-  client_id: '{CLIENT_ID}',  // Optional field.
-  username: '{USERNAME}',
-  password: '{PASSWORD}',
-  connection: '{CONNECTION_NAME}',
-  scope: 'openid'  // Optional field.
-};
-
-auth0.oauth.signIn(data, function (err, userData) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userData);
-});
- -
- -
- - -
- - - -

socialSignIn(data) → {Promise|undefined}

- - - - - -
-

Sign in using a social provider access token.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
data - - -Object - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
access_token - - -String - - - - -

User access token.

- -
connection - - -String - - - - -

Identity provider.

- -
- - -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-auth.PasswordlessAuthenticator.html b/docs/module-auth.PasswordlessAuthenticator.html deleted file mode 100644 index e81cdc6c4..000000000 --- a/docs/module-auth.PasswordlessAuthenticator.html +++ /dev/null @@ -1,1501 +0,0 @@ - - - - - - PasswordlessAuthenticator - Documentation - - - - - - - - - - - - - - - - - -
- -

PasswordlessAuthenticator

- - - - - - - -
- -
- -

- auth. - - PasswordlessAuthenticator -

- -

Handles authenticator with passwordless flows, e.g. SMS, Touch ID, etc.

- - -
- -
-
- - -
- - -

Constructor

- - -

new PasswordlessAuthenticator(options, oauth)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

Authenticator options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The auth0 account URL.

- -
clientId - - -String - - - - - - <optional>
- - - - - -
-

Default client ID.

- -
- - -
oauth - - -OAuthAuthenticator - - - - -

OAuthAuthenticator instance.

- -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instace.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

sendEmail(userData, cbopt) → {Promise|undefined}

- - - - - -
-

Start passwordless flow sending an email.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
userData - - -Object - - - - - - - - - - -

User account data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
email - - -String - - - - -

User email address.

- -
send - - -String - - - - -

The type of email to be sent.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Method callback.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user `email` address, it will send an email with: - -

    -
  • A link (default, `send:"link"`). You can then authenticate with this - user opening the link and he will be automatically logged in to the - application. Optionally, you can append/override parameters to the link - (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using - `authParams` object. -
  • -
  • - A verification code (`send:"code"`). You can then authenticate with - this user using the `/oauth/ro` endpoint specifying `email` as - `username` and `code` as `password`. -
  • -
- - Find more information in the - API Docs -

- -
var data = {
-  email: '{EMAIL}',
-  send: 'link',
-  authParams: {} // Optional auth params.
-};
-
-auth0.passwordless.sendEmail(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -
- -
- - -
- - - -

sendSMS(userData, cbopt) → {Promise|undefined}

- - - - - -
-

Start passwordless flow sending an SMS.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
userData - - -Object - - - - - - - - - - -

User account data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
phone_number - - -String - - - - - - - - - - -

User phone number.

- -
client_id - - -String - - - - - - <optional>
- - - - - -
-

Client ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Method callback.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Given the user `phone_number`, it will send a SMS message with a - verification code. You can then authenticate with this user using the - `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as - `password`: -

- -
var data = {
-  phone_number: '{PHONE}'
-};
-
-auth0.passwordless.sendSMS(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -
- -
- - -
- - - -

signIn(userData, cbopt) → {Promise|undefined}

- - - - - -
-

Sign in with the given user credentials.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
userData - - -Object - - - - - - - - - - -

User credentials object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
username - - -String - - - - - - - - - - - - -

Username.

- -
password - - -String - - - - - - - - - - - - -

Password.

- -
connection - - -String - - - - - - <optional>
- - - - - -
- - sms - - -

Connection string: "sms" or "email".

- -
client_id - - -String - - - - - - <optional>
- - - - - -
- - -

Client ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Method callback.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Examples
- -

- Given the user credentials (`phone_number` and `code`), it will do the - authentication on the provider and return a JSON with the `access_token` - and `id_token`. -

- -
var data = {
-  username: '{PHONE_NUMBER}',
-  password: '{VERIFICATION_CODE}'
-};
-
-auth0.passwordless.signIn(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -

- The user data object has the following structure. -

- -
{
-  id_token: String,
-  access_token: String,
-  token_type: String
-}
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-auth.TokensManager.html b/docs/module-auth.TokensManager.html deleted file mode 100644 index 97a1daf27..000000000 --- a/docs/module-auth.TokensManager.html +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - TokensManager - Documentation - - - - - - - - - - - - - - - - - -
- -

TokensManager

- - - - - - - -
- -
- -

- auth. - - TokensManager -

- -

Provides methods for getting token data and exchanging tokens.

- - -
- -
-
- - -
- - -

Constructor

- - -

new TokensManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

Manager options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The auth0 account URL.

- -
headers - - -String - - - - - - <optional>
- - - - - -
-

Default request headers.

- -
clientId - - -String - - - - - - <optional>
- - - - - -
-

Default client ID.

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-auth.UsersManager.html b/docs/module-auth.UsersManager.html deleted file mode 100644 index 1b625dd20..000000000 --- a/docs/module-auth.UsersManager.html +++ /dev/null @@ -1,1018 +0,0 @@ - - - - - - UsersManager - Documentation - - - - - - - - - - - - - - - - - -
- -

UsersManager

- - - - - - - -
- -
- -

- auth. - - UsersManager -

- -

Provides methods for getting user information and impersonating users.

- - -
- -
-
- - -
- - -

Constructor

- - -

new UsersManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

Manager options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The auth0 account URL.

- -
headers - - -String - - - - - - <optional>
- - - - - -
-

Default request headers.

- -
clientId - - -String - - - - - - <optional>
- - - - - -
-

Default client ID.

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - -

Methods

- - - -
- - - -

getInfo(accessToken, cbopt) → {Promise|undefined}

- - - - - -
-

Given an access token get the user profile linked to it.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
accessToken - - -String - - - - - - - - - - -

User access token.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Get the user information based on the Auth0 access token (obtained during - login). Find more information in the - API Docs. -

- -
auth0.users.getInfo(accessToken, function (err, userInfo) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(userInfo);
-});
- -
- -
- - -
- - - -

impersonate(userId, settings, cbopt) → {Promise|undefined}

- - - - - -
-

Impersonate the user with the given user ID.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
userId - - -String - - - - - - - - - - -

User ID token.

- -
settings - - -Object - - - - - - - - - - -

Impersonation settings.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
impersonator_id - - -String - - - - - - - - - - -

Impersonator user ID.

- -
protocol - - -String - - - - - - - - - - -

The authentication protocol.

- -
token - - -String - - - - - - - - - - -

API v1 token obtained for impersonation

- -
clientId - - -String - - - - - - <optional>
- - - - - -
-

Client id used for impersonation. Uses the one supplied in the constructor by default.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- Gets a link that can be used once to log in as a specific user. Useful for - troubleshooting. Find more information in the - [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate). -

- -
var settings = {
-  impersonator_id: '{IMPERSONATOR_ID}',
-  protocol: 'oauth2',
-  additionalParameters: {}  // Optional aditional params.
-};
-
-auth0.users.impersonate(userId, settings, function (err, link) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(link);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-auth.html b/docs/module-auth.html deleted file mode 100644 index 249e89209..000000000 --- a/docs/module-auth.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - auth - Documentation - - - - - - - - - - - - - - - - - -
- -

auth

- - - - - - - -
- -
- - - -
- - - -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.BlacklistedTokensManager.html b/docs/module-management.BlacklistedTokensManager.html deleted file mode 100644 index 0451d5674..000000000 --- a/docs/module-management.BlacklistedTokensManager.html +++ /dev/null @@ -1,1000 +0,0 @@ - - - - - - BlacklistedTokensManager - Documentation - - - - - - - - - - - - - - - - - -
- -

BlacklistedTokensManager

- - - - - - - -
- -
- -

- management. - - BlacklistedTokensManager -

- -

BlacklistedTokensManager -The BlacklistedTokensManager class provides methods to retrieve the list of -blacklisted tokens and blacklist new ones..

- - -
- -
-
- - -
- - -

Constructor

- - -

new BlacklistedTokensManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Auth0 Blacklisted Tokens endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instace.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

add(token, cbopt) → {Promise|undefined}

- - - - - -
-

Blacklist a new token.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
token - - -Object - - - - - - - - - - -

Token data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
aud - - -String - - - - -

Audience (your app client ID).

- -
jti - - -String - - - - -

The JWT ID claim.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var token = {
- aud: 'aud',
- jti: 'jti'
-};
-
-management.blacklistedTokens.add(token, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Token blacklisted.
-});
- -
- -
- - -
- - - -

getAll(cbopt) → {Promise|undefined}

- - - - - -
-

Get all blacklisted tokens.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.blacklistedTokens.getAll(function (err, tokens) {
-  console.log(tokens.length);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.ClientGrantsManager.html b/docs/module-management.ClientGrantsManager.html deleted file mode 100644 index dee679a9a..000000000 --- a/docs/module-management.ClientGrantsManager.html +++ /dev/null @@ -1,2769 +0,0 @@ - - - - - - ClientGrantsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

ClientGrantsManager

- - - - - - - -
- -
- -

- management. - - ClientGrantsManager -

- -

ClientGrantsManager -Auth0 Client Grants Manager.

-

See Client Grants

- - -
- -
-
- - -
- - -

Constructor

- - -

new ClientGrantsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Auth0 Client Grants endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create an Auth0 client grant.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The client data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.clientGrants.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Client grant created.
-});
- -
- -
- - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create an Auth0 client grant.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The client data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.clientGrants.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Client grant created.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete an Auth0 client grant.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Client parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Client grant ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.clientGrants.delete({ id: GRANT_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Grant deleted.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete an Auth0 client grant.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Client parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Client grant ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.clientGrants.delete({ id: GRANT_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Grant deleted.
-});
- -
- -
- - -
- - - -

getAll(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all Auth0 Client Grants.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Client Grants parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number, zero indexed.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
-
-management.getClientGrants(params, function (err, grants) {
-  console.log(grants.length);
-});
- -
- -
- - -
- - - -

getAll(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all Auth0 Client Grants.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Client Grants parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number, zero indexed.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
-
-
-management.clientGrants.getAll(params, function (err, grants) {
-  console.log(grants.length);
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update an Auth0 client grant.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Client parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Client grant ID.

- -
- - -
data - - -Object - - - - - - - - - - -

Updated client data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var data = {
-  client_id: CLIENT_ID,
-  audience: AUDIENCE,
-  scope: []
-};
-var params = { id: CLIENT_GRANT_ID };
-
-management.clientGrants.update(params, data, function (err, grant) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(grant.id);
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update an Auth0 client grant.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Client parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Client grant ID.

- -
- - -
data - - -Object - - - - - - - - - - -

Updated client data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var data = {
-  client_id: CLIENT_ID,
-  audience: AUDIENCE,
-  scope: []
-};
-var params = { id: CLIENT_GRANT_ID };
-
-management.clientGrants.update(params, data, function (err, grant) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(grant.id);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.ClientsManager.html b/docs/module-management.ClientsManager.html deleted file mode 100644 index 02612947b..000000000 --- a/docs/module-management.ClientsManager.html +++ /dev/null @@ -1,1913 +0,0 @@ - - - - - - ClientsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

ClientsManager

- - - - - - - -
- -
- -

- management. - - ClientsManager -

- -

ClientsManager -Auth0 Clients Manager.

-

Clients represent -applications. -You can learn more about this in the -Applications section of the -documentation.

- - -
- -
-
- - -
- - -

Constructor

- - -

new ClientsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Auth0 Clients endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create an Auth0 client.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The client data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.clients.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Client created.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete an Auth0 client.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Client parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
client_id - - -String - - - - -

Application client ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.clients.delete({ client_id: CLIENT_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Client deleted.
-});
- -
- -
- - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get an Auth0 client.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Client parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
client_id - - -String - - - - -

Application client ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.clients.get({ client_id: CLIENT_ID }, function (err, client) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(client);
-});
- -
- -
- - -
- - - -

getAll(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all Auth0 clients.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Clients parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number, zero indexed.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
-
-management.clients.getAll(params, function (err, clients) {
-  console.log(clients.length);
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update an Auth0 client.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Client parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
client_id - - -String - - - - -

Application client ID.

- -
- - -
data - - -Object - - - - - - - - - - -

Updated client data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var data = { name: 'newClientName' };
-var params = { client_id: CLIENT_ID };
-
-management.clients.update(params, data, function (err, client) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(client.name);  // 'newClientName'
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.ConnectionsManager.html b/docs/module-management.ConnectionsManager.html deleted file mode 100644 index 7ebfbcc77..000000000 --- a/docs/module-management.ConnectionsManager.html +++ /dev/null @@ -1,1908 +0,0 @@ - - - - - - ConnectionsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

ConnectionsManager

- - - - - - - -
- -
- -

- management. - - ConnectionsManager -

- -

ConnectionsManager -Represents the relationship between Auth0 and an Identity provider.

- - -
- -
-
- - -
- - -

Constructor

- - -

new ConnectionsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for performing CRUD operations on -Auth0 Connections.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create a new connection.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

Connection data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.connections.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Conection created.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete an existing connection.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Connection parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Connection ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.connections.delete({ id: CONNECTION_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Conection deleted.
-});
- -
- -
- - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get an Auth0 connection.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Connection parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Connection ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.connections.get({ id: CONNECTION_ID }, function (err, connection) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(connection);
-});
- -
- -
- - -
- - - -

getAll(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all connections.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Connections params.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number, zero indexed.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
-
-management.connections.getAll(params, function (err, connections) {
-  console.log(connections.length);
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update an existing connection.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Conneciton parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Connection ID.

- -
- - -
data - - -Object - - - - - - - - - - -

Updated connection data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var data = { name: 'newConnectionName' };
-var params = { id: CONNECTION_ID };
-
-management.connections.update(params, data, function (err, connection) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(connection.name);  // 'newConnectionName'
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.CustomDomainsManager.html b/docs/module-management.CustomDomainsManager.html deleted file mode 100644 index 6c4def656..000000000 --- a/docs/module-management.CustomDomainsManager.html +++ /dev/null @@ -1,2881 +0,0 @@ - - - - - - CustomDomainsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

CustomDomainsManager

- - - - - - - -
- -
- -

- management. - - CustomDomainsManager -

- -

CustomDomainsManager -Auth0 Custom Domains Manager.

-

CustomDomains represent -custom domain names. -You can learn more about this in the -CustomDomains section of the -documentation.

- - -
- -
-
- - -
- - -

Constructor

- - -

new CustomDomainsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0CustomDomainsRestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Auth0 Custom Domains endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) auth0VerifyRestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Auth0 Custom Domains Verify endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create an Auth0 Custom Domain.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The custom domain data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.customDomains.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // CustomDomain created.
-});
- -
- -
- - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create an Auth0 Custom Domain.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The custom domain data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.createCustomDomain(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // CustomDomain created.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete a Custom Domain.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Custom Domain parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Custom Domain ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.deleteCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // CustomDomain deleted.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete a Custom Domain.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Custom Domain parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Custom Domain ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.customDomains.delete({ id: CUSTOM_DOMAIN_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // CustomDomain deleted.
-});
- -
- -
- - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get a Custom Domain.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Custom Domain parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Custom Domain ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.getCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(customDomain);
-});
- -
- -
- - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get a Custom Domain.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Custom Domain parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Custom Domain ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.customDomains.get({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(customDomain);
-});
- -
- -
- - -
- - - -

getAll() → {Promise|undefined}

- - - - - -
-

Get all Auth0 CustomDomains.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.getCustomDomains(function (err, customDomains) {
-  console.log(customDomains.length);
-});
- -
- -
- - -
- - - -

getAll() → {Promise|undefined}

- - - - - -
-

Get all Auth0 CustomDomains.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.customDomains.getAll(function (err, customDomains) {
-  console.log(customDomains.length);
-});
- -
- -
- - -
- - - -

verify(params, cbopt) → {Promise|undefined}

- - - - - -
-

Verify a Custom Domain.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Custom Domain parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Custom Domain ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.verifyCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(customDomain);
-});
- -
- -
- - -
- - - -

verify(params, cbopt) → {Promise|undefined}

- - - - - -
-

Verify a Custom Domain.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Custom Domain parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Custom Domain ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.customDomains.verify({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(customDomain);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.DeviceCredentialsManager.html b/docs/module-management.DeviceCredentialsManager.html deleted file mode 100644 index 01d6666b7..000000000 --- a/docs/module-management.DeviceCredentialsManager.html +++ /dev/null @@ -1,1188 +0,0 @@ - - - - - - DeviceCredentialsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

DeviceCredentialsManager

- - - - - - - -
- -
- -

- management. - - DeviceCredentialsManager -

- -

DeviceCredentialsManager -Manages Auth0 Device Credentials.

- - -
- -
-
- - -
- - -

Constructor

- - -

new DeviceCredentialsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the - Auth0 DeviceCredentialsManagers endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the RestClient instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create an Auth0 credential.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The device credential data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.deviceCredentials.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Credential created.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete an Auth0 device credential.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Credential parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Device credential ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = { id: CREDENTIAL_ID };
-
-management.deviceCredentials.delete(params, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Credential deleted.
-});
- -
- -
- - -
- - - -

getAll(cbopt) → {Promise|undefined}

- - - - - -
-

Get all Auth0 credentials.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.deviceCredentials.getAll(function (err, credentials) {
-  console.log(credentials.length);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.EmailProviderManager.html b/docs/module-management.EmailProviderManager.html deleted file mode 100644 index 52441ed0a..000000000 --- a/docs/module-management.EmailProviderManager.html +++ /dev/null @@ -1,1354 +0,0 @@ - - - - - - EmailProviderManager - Documentation - - - - - - - - - - - - - - - - - -
- -

EmailProviderManager

- - - - - - - -
- -
- -

- management. - - EmailProviderManager -

- -

EmailProviderManager -Auth0 Email Provider.

- - -
- -
-
- - -
- - -

Constructor

- - -

new EmailProviderManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Auth0 Clients endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

configure(data, cbopt) → {Promise|undefined}

- - - - - -
-

Configure the email provider.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The email provider data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.emailProvider.configure(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Email provider configured.
-});
- -
- -
- - -
- - - -

delete(cbopt) → {Promise|undefined}

- - - - - -
-

Delete email provider.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.emailProvider.delete(function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Email provider configured.
-});
- -
- -
- - -
- - - -

get(cbopt) → {Promise|undefined}

- - - - - -
-

Get the email provider.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.emailProvider.get(function (err, provider) {
-  console.log(provider);
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update the email provider.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Email provider parameters.

- -
data - - -Object - - - - - - - - - - -

Updated email provider data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.emailProvider.update(params, data, function (err, provider) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Updated email provider.
-  console.log(provider);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.EmailTemplatesManager.html b/docs/module-management.EmailTemplatesManager.html deleted file mode 100644 index 2495916b4..000000000 --- a/docs/module-management.EmailTemplatesManager.html +++ /dev/null @@ -1,1313 +0,0 @@ - - - - - - EmailTemplatesManager - Documentation - - - - - - - - - - - - - - - - - -
- -

EmailTemplatesManager

- - - - - - - -
- -
- -

- management. - - EmailTemplatesManager -

- -

EmailTemplatesManager -This class provides a simple abstraction for performing CRUD operations -on Auth0's Email Templates. {@see https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName}

- - -
- -
-
- - -
- - -

Constructor

- - -

new EmailTemplatesManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for performing CRUD operations on -Auth0's Email Templates.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create a new Email Template.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

Email Template data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.emailTemplates.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Email Template created.
-});
- -
- -
- - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get an Auth0 Email Template.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Email Template parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -String - - - - -

Template Name

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.emailTemplates.get({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(emailTemplate);
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update an existing Email Template.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Email Template parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
name - - -String - - - - -

Template Name

- -
- - -
data - - -Object - - - - - - - - - - -

Updated Email Template data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var data = { from: 'new@email.com' };
-var params = { name: EMAIL_TEMPLATE_NAME };
-
-management.emailTemplates.update(params, data, function (err, emailTemplate) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(emailTemplate.from);  // 'new@email.com'
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.GuardianManager.html b/docs/module-management.GuardianManager.html deleted file mode 100644 index eff768fda..000000000 --- a/docs/module-management.GuardianManager.html +++ /dev/null @@ -1,1629 +0,0 @@ - - - - - - GuardianManager - Documentation - - - - - - - - - - - - - - - - - -
- -

GuardianManager

- - - - - - - -
- -
- -

- management. - - GuardianManager -

- -

Abstracts interaction with the Guardian endpoint.

- - -
- -
-
- - -
- - -

Constructor

- - -

new GuardianManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) guardianEnrollmentsAuth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for retrieving Guardian enrollments.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) guardianFactorsAuth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for retrieving Guardian factors.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) guardianFactorsProvidersAuth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for retrieving Guardian factor providers.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) guardianFactorsTemplatesAuth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for retrieving Guardian factors.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) guardianTicketsAuth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for retrieving Guardian tickets.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - - - -

Methods

- - - -
- - - -

createEnrollmentTicket(cbopt) → {Promise|undefined}

- - - - - -
-

Create a Guardian enrollment ticket.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.guardian.createEnrollmentTicket(function (err, ticket) {
-  console.log(ticket);
-});
- -
- -
- - -
- - - -

createGuardianEnrollmentTicket(cbopt) → {Promise|undefined}

- - - - - -
-

Create a Guardian enrollment ticket.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.createGuardianEnrollmentTicket(function (err, ticket) {
-  console.log(ticket);
-});
- -
- -
- - -
- - - -

deleteGuardianEnrollment(data, cbopt) → {Promise|undefined}

- - - - - -
-

Delete a Guardian enrollment.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The user data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.guardian.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollments) {
-  console.log(enrollments);
-});
- -
- -
- - -
- - - -

getGuardianEnrollment(data, cbopt) → {Promise|undefined}

- - - - - -
-

Get a single Guardian enrollment.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The user data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.guardian.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) {
-  console.log(enrollment);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.JobsManager.html b/docs/module-management.JobsManager.html deleted file mode 100644 index a17cf8ff0..000000000 --- a/docs/module-management.JobsManager.html +++ /dev/null @@ -1,1369 +0,0 @@ - - - - - - JobsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

JobsManager

- - - - - - - -
- -
- -

- management. - - JobsManager -

- -

Abstract the creation as well as the retrieval of async jobs.

- - -
- -
-
- - -
- - -

Constructor

- - -

new JobsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Jobs endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - - - -

Methods

- - - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get a job by its ID.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Job parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Job ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = {
-  id: '{JOB_ID}'
-};
-
-management.jobs.get(params, function (err, job) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Retrieved job.
-  console.log(job);
-});
- -
- -
- - -
- - - -

importUsers(data, cbopt) → {Promise|undefined}

- - - - - -
-

Given a path to a file and a connection id, create a new job that imports the -users contained in the file or JSON string and associate them with the given -connection.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

Users import data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
connectionId - - -String - - - - -

Connection for the users insertion.

- -
users - - -String - - - - -

Path to the users data file.

- -
users_json - - -String - - - - -

JSON data for the users.

- -
upsert - - -String - - - - -

OPTIONAL: set to true to upsert users, defaults to false

- -
send_completion_email - - -String - - - - -

OPTIONAL: defaults to true

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = {
-  connection_id: '{CONNECTION_ID}',
-  users: '{PATH_TO_USERS_FILE}',
-  upsert: true, //optional
-  send_completion_email: false //optional
-};
-
-management.jobs.get(params, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -
- -
- - -
- - - -

verifyEmail(data, cbopt) → {Promise|undefined}

- - - - - -
-

Send a verification email to a user.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

User data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
user_id - - -String - - - - -

ID of the user to be verified.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = {
-	user_id: '{USER_ID}'
-};
-
-management.jobs.verifyEmail(function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.LogsManager.html b/docs/module-management.LogsManager.html deleted file mode 100644 index a476b9d52..000000000 --- a/docs/module-management.LogsManager.html +++ /dev/null @@ -1,1295 +0,0 @@ - - - - - - LogsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

LogsManager

- - - - - - - -
- -
- -

- management. - - LogsManager -

- -

LogsManager -Represents the relationship between Auth0 and an Identity provider.

- - -
- -
-
- - -
- - -

Constructor

- - -

new LogsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for performing CRUD operations on -Auth0 Logs.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get an Auth0 log.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Log parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Log ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.logs.get({ id: EVENT_ID }, function (err, log) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(log);
-});
- -
- -
- - -
- - - -

getAll(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all logs.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Logs params.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
q - - -String - - - - - - <optional>
- - - - - -
-

Search Criteria using Query String Syntax

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number. Zero based

- -
per_page - - -Number - - - - - - <optional>
- - - - - -
-

The amount of entries per page

- -
sort - - -String - - - - - - <optional>
- - - - - -
-

The field to use for sorting.

- -
fields - - -String - - - - - - <optional>
- - - - - -
-

A comma separated list of fields to include or exclude

- -
include_fields - - -Boolean - - - - - - <optional>
- - - - - -
-

true if the fields specified are to be included in the result, false otherwise.

- -
include_totals - - -Boolean - - - - - - <optional>
- - - - - -
-

true if a query summary must be included in the result, false otherwise. Default false

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings and the search query. If pagination options are - not present, the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 2
-};
-
-management.logs.getAll(params, function (err, logs) {
-  console.log(logs.length);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.ManagementTokenProvider.html b/docs/module-management.ManagementTokenProvider.html deleted file mode 100644 index 98a360c74..000000000 --- a/docs/module-management.ManagementTokenProvider.html +++ /dev/null @@ -1,642 +0,0 @@ - - - - - - ManagementTokenProvider - Documentation - - - - - - - - - - - - - - - - - -
- -

ManagementTokenProvider

- - - - - - - -
- -
- -

- management. - - ManagementTokenProvider -

- -

ManagementTokenProvider -Auth0 Management API Token Provider.

- - -
- -
-
- - -
- - -

Constructor

- - -

new ManagementTokenProvider(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

Options for the ManagementTokenProvider.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
domain - - -String - - - - - - - - - - - - -

ManagementClient server domain.

- -
clientId - - -String - - - - - - - - - - - - -

Non Interactive Client Id.

- -
clientSecret - - -String - - - - - - - - - - - - -

Non Interactive Client Secret.

- -
scope - - -String - - - - - - - - - - - - -

Non Interactive Client Scope.

- -
audience - - -String - - - - - - - - - - - - -

Audience of the Management API.

- -
enableCache - - -Boolean - - - - - - <optional>
- - - - - -
- - true - - -

Enabled or Disable Cache

- -
cacheTTLInSeconds - - -Number - - - - - - <optional>
- - - - - -
- - -

By default the expires_in value will be used to determine the cached time of the token, this can be overridden.

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - -

Methods

- - - -
- - - -

getAccessToken() → {Promise}

- - - - - -
-

Returns the access_token.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise - - -
-
- - -
-

Promise returning an access_token.

-
- - -
- - - -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.ResourceServersManager.html b/docs/module-management.ResourceServersManager.html deleted file mode 100644 index 0c021904e..000000000 --- a/docs/module-management.ResourceServersManager.html +++ /dev/null @@ -1,1913 +0,0 @@ - - - - - - ResourceServersManager - Documentation - - - - - - - - - - - - - - - - - -
- -

ResourceServersManager

- - - - - - - -
- -
- -

- management. - - ResourceServersManager -

- -

ResourceServersManager -Auth0 Resource Servers Manager.

-

Resource Servers represents -your APIs. -You can learn more about this in the -API Authorization section of the -documentation.

- - -
- -
-
- - -
- - -

Constructor

- - -

new ResourceServersManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Auth0 Resource Servers endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create an API (Resource Server).

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

Resource Server data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.resourceServers.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Resource Server created.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete an existing Resource Server.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Resource Server parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Resource Server ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.resourceServers.delete({ id: RESOURCE_SERVER_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Resource Server deleted.
-});
- -
- -
- - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get a Resource Server.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Resource Server parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Resource Server ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.resourceServers.get({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(resourceServer);
-});
- -
- -
- - -
- - - -

getAll(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all resource servers.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Resource Servers parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number, zero indexed.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
-
-management.resourceServers.getAll(params, function (err, resourceServers) {
-  console.log(resourceServers.length);
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update an existing resource server.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Resource Server parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Resource Server ID.

- -
- - -
data - - -Object - - - - - - - - - - -

Updated Resource Server data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var data = { name: 'newResourceServerName' };
-var params = { id: RESOURCE_SERVER_ID };
-
-management.resourceServers.update(params, data, function (err, resourceServer) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(resourceServer.name);  // 'newResourceServernName'
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.RetryRestClient.html b/docs/module-management.RetryRestClient.html deleted file mode 100644 index 482cb0539..000000000 --- a/docs/module-management.RetryRestClient.html +++ /dev/null @@ -1,386 +0,0 @@ - - - - - - RetryRestClient - Documentation - - - - - - - - - - - - - - - - - -
- -

RetryRestClient

- - - - - - - -
- -
- -

- management. - - RetryRestClient -

- -

RetryRestClient -Wrapper Rest Client that adds Retry functionality when requests are failing due to rate limiting (status code 429).

- - -
- -
-
- - -
- - -

Constructor

- - -

new RetryRestClient(restClient, optionsopt)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
restClient - - -Object - - - - - - - - - - -

RestClient.

- -
options - - -Object - - - - - - <optional>
- - - - - -
-

Options for the RetryRestClient.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
enabled:true - - -Object - - - - - - <optional>
- - - - - -
- - -

Enabled or Disable Retry Policy functionality.

- -
maxRetries - - -Number - - - - - - <optional>
- - - - - -
- - 10 - - -

The maximum amount of times to retry the operation. Default is 10.

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.RulesConfigsManager.html b/docs/module-management.RulesConfigsManager.html deleted file mode 100644 index 4a371256c..000000000 --- a/docs/module-management.RulesConfigsManager.html +++ /dev/null @@ -1,1326 +0,0 @@ - - - - - - RulesConfigsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

RulesConfigsManager

- - - - - - - -
- -
- -

- management. - - RulesConfigsManager -

- -

RulesConfigsManager -The rules configs manager class provides a simple abstraction for performing CRUD operations -on Auth0 RulesConfigsManager.

- - -
- -
-
- - -
- - -

Constructor

- - -

new RulesConfigsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for performing CRUD operations on -Auth0 RulesConfigsManager.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete an existing rules config.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Rule Configs parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
key - - -String - - - - -

Rule Configs key.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.rulesConfigs.delete({ key: RULE_CONFIG_KEY }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Rules Config deleted.
-});
- -
- -
- - -
- - - -

getAll(cbopt) → {Promise|undefined}

- - - - - -
-

Get all rules configs.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.rulesConfigs.getAll(function (err, rulesConfig) {
-  console.log(rulesConfig.length);
-});
- -
- -
- - -
- - - -

set(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Set a new rules config.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Rule Config parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
key - - -String - - - - -

Rule Config key.

- -
- - -
data - - -Object - - - - - - - - - - -

Rule Config Data parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
value - - -String - - - - -

Rule Config Data value.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = { key: RULE_CONFIG_KEY };
-var data =   { value: RULES_CONFIG_VALUE };
- 
-management.rulesConfigs.set(params, data, function (err, rulesConfig) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Rules Config set.
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.RulesManager.html b/docs/module-management.RulesManager.html deleted file mode 100644 index c81f2d396..000000000 --- a/docs/module-management.RulesManager.html +++ /dev/null @@ -1,1919 +0,0 @@ - - - - - - RulesManager - Documentation - - - - - - - - - - - - - - - - - -
- -

RulesManager

- - - - - - - -
- -
- -

- management. - - RulesManager -

- -

RulesManager -The rule class provides a simple abstraction for performing CRUD operations -on Auth0 RulesManagers.

- - -
- -
-
- - -
- - -

Constructor

- - -

new RulesManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for performing CRUD operations on -Auth0 RulesManagers.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) clientOptions :Object

- - - - -
-

Options object for the Rest Client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
-
    -
  • - -Object - - -
  • -
- - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create a new rule.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

Rule data object.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.rules.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Rule created.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete an existing rule.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Rule parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Rule ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.rules.delete({ id: RULE_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Rule deleted.
-});
- -
- -
- - -
- - - -

get(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get an Auth0 rule.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Rule parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Rule ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.rules.get({ id: RULE_ID }, function (err, rule) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(rule);
-});
- -
- -
- - -
- - - -

getAll(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all rules.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Rules parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number, zero indexed.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings. If pagination options are not present, - the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
-
-management.rules.getAll(params, function (err, rules) {
-  console.log(rules.length);
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update an existing rule.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Rule parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Rule ID.

- -
- - -
data - - -Object - - - - - - - - - - -

Updated rule data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var data = { name: 'New name' };
-var params = { id: RULE_ID };
-
-// Using auth0 instance.
-management.updateRule(params, data, function (err, rule) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(rule.name);  // 'New name'
-});
-
-// Using the rules manager directly.
-management.rules.update(params, data, function (err, rule) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(rule.name);  // 'New name'
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.StatsManager.html b/docs/module-management.StatsManager.html deleted file mode 100644 index d73bbea41..000000000 --- a/docs/module-management.StatsManager.html +++ /dev/null @@ -1,928 +0,0 @@ - - - - - - StatsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

StatsManager

- - - - - - - -
- -
- -

- management. - - StatsManager -

- -

Abstracts interaction with the stats endpoint.

- - -
- -
-
- - -
- - -

Constructor

- - -

new StatsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Stats endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - - - -

Methods

- - - -
- - - -

getActiveUsersCount(cbopt) → {Promise|undefined}

- - - - - -
-

Get a the active users count.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.stats.getActiveUsersCount(function (err, usersCount) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(usersCount);
-});
- -
- -
- - -
- - - -

getDaily(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get the daily stats.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Stats parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
from - - -String - - - - -

The first day in YYYYMMDD format.

- -
to - - -String - - - - -

The last day in YYYYMMDD format.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = {
-  from: '{YYYYMMDD}',  // First day included in the stats.
-  to: '{YYYYMMDD}'  // Last day included in the stats.
-};
-
-management.stats.getDaily(params, function (err, stats) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(stats);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.TenantManager.html b/docs/module-management.TenantManager.html deleted file mode 100644 index 527516334..000000000 --- a/docs/module-management.TenantManager.html +++ /dev/null @@ -1,844 +0,0 @@ - - - - - - TenantManager - Documentation - - - - - - - - - - - - - - - - - -
- -

TenantManager

- - - - - - - -
- -
- -

- management. - - TenantManager -

- -

Abstracts interaction with the tenant endpoint.

- - -
- -
-
- - -
- - -

Constructor

- - -

new TenantManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Stats endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - - - -

Methods

- - - -
- - - -

getSettings(cbopt) → {Promise|undefined}

- - - - - -
-

Get the tenant settings..

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.tenant.getSettings(function (err, settings) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(settings);
-});
- -
- -
- - -
- - - -

updateSettings(data, cbopt) → {Promise|undefined}

- - - - - -
-

Update the tenant settings.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The new tenant settings.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.tenant.updateSettings(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.TicketsManager.html b/docs/module-management.TicketsManager.html deleted file mode 100644 index 6cc15b131..000000000 --- a/docs/module-management.TicketsManager.html +++ /dev/null @@ -1,814 +0,0 @@ - - - - - - TicketsManager - Documentation - - - - - - - - - - - - - - - - - -
- -

TicketsManager

- - - - - - - -
- -
- -

- management. - - TicketsManager -

- -

Abstracts interaction with the tickets endpoint.

- - -
- -
-
- - -
- - -

Constructor

- - -

new TicketsManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) auth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Tickets endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - - - -

Methods

- - - -
- - - -

changePassword(cbopt) → {Promise}

- - - - - -
-

Create a new password change ticket.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise - - -
-
- - - -
- - - -
-
Example
- -
var params = {
-  result_url: '{REDIRECT_URL}',  // Redirect after using the ticket.
-  user_id: '{USER_ID}',  // Optional.
-  email: '{USER_EMAIL}',  // Optional.
-  new_password: '{PASSWORD}'
-};
-
-management.tickets.changePassword(params, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -
- -
- - -
- - - -

verifyEmail(cbopt) → {Promise}

- - - - - -
-

Create an email verification ticket.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise - - -
-
- - - -
- - - -
-
Example
- -
var data = {
-  user_id: '{USER_ID}',
-  result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
-};
-
-management.tickets.verifyEmail(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.UsersManager.html b/docs/module-management.UsersManager.html deleted file mode 100644 index 4a29c2bcb..000000000 --- a/docs/module-management.UsersManager.html +++ /dev/null @@ -1,5084 +0,0 @@ - - - - - - UsersManager - Documentation - - - - - - - - - - - - - - - - - -
- -

UsersManager

- - - - - - - -
- -
- -

- management. - - UsersManager -

- -

Abstracts interaction with the users endpoint.

- - -
- -
-
- - -
- - -

Constructor

- - -

new UsersManager(options)

- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
options - - -Object - - - - -

The client options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
baseUrl - - -String - - - - - - - - - - -

The URL of the API.

- -
headers - - -Object - - - - - - <optional>
- - - - - -
-

Headers to be included in all requests.

- -
retry - - -Object - - - - - - <optional>
- - - - - -
-

Retry Policy Config

- -
- - -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -

Members

- - - -
-

(inner) enrollmentsAuth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for retrieving Guardian enrollments.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) identitiesAuth0RestClient :external:RestClient

- - - - -
-

Provides a simple abstraction layer for linking user accounts.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) multifactorAuth0RestClient :external:RestClient

- - - - -
-

Provides an abstraction layer for consuming the -Multifactor Provider endpoint.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) recoveryCodeRegenerationAuth0RestClients :external:RestClient

- - - - -
-

Provides an abstraction layer for regenerating Guardian recovery codes.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) userLogsAuth0RestClient :external:RestClient

- - - - -
-

Provides a simple abstraction layer for user logs

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - -
-

(inner) usersByEmailClient :external:RestClient

- - - - -
-

Provides an abstraction layer for the new "users-by-email" API

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
Type:
- - - - - - -
- - - - - -

Methods

- - - -
- - - -

create(data, cbopt) → {Promise|undefined}

- - - - - -
-

Create a new user.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

User data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.users.create(data, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // User created.
-});
- -
- -
- - -
- - - -

delete(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete a user by its id.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

The user data object..

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.users.delete({ id: USER_ID }, function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // User deleted.
-});
- -
- -
- - -
- - - -

deleteAll(cbopt) → {Promise|undefined}

- - - - - -
-

Delete all users.

-
- - - - - -
- - - - - - - - - - - - - - - - -
Deprecated:
  • This method will be removed in the next major release.
- - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.users.deleteAll(function (err) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Users deleted
-});
- -
- -
- - -
- - - -

deleteMultifactorProvider(params, cbopt) → {Promise|undefined}

- - - - - -
-

Delete a multifactor provider.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
provider - - -String - - - - -

Multifactor provider.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };
-
-management.users.deleteMultifactorProvider(params, function (err, user) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Users accounts unlinked.
-});
- -
- -
- - -
- - - -

get(data, cbopt) → {Promise|undefined}

- - - - - -
-

Get a user by its id.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The user data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.users.get({ id: USER_ID }, function (err, user) {
-  console.log(user);
-});
- -
- -
- - -
- - - -

getAll(paramsopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get all users.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - <optional>
- - - - - -
-

Users params.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
per_page - - -Number - - - - - - <optional>
- - - - - -
-

Number of results per page.

- -
page - - -Number - - - - - - <optional>
- - - - - -
-

Page number, zero indexed.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes an optional object as first argument that may be used to - specify pagination settings and the search query. If pagination options are - not present, the first page of a limited number of results will be returned. -

- -
// Pagination settings.
-var params = {
-  per_page: 10,
-  page: 0
-};
-
-management.users.getAll(params, function (err, users) {
-  console.log(users.length);
-});
- -
- -
- - -
- - - -

getByEmail(emailopt, cbopt) → {Promise|undefined}

- - - - - -
-

Get Users by an Email Address

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
email - - -String - - - - - - <optional>
- - - - - -
-

Email address of user(s) to find

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -

- This method takes a first argument as the Email address to look for - users, and uses the /users-by-email API, not the search API -

- -
management.users.getByEmail('email@address', function (err, users) {
-  console.log(users);
-});
- -
- -
- - -
- - - -

getGuardianEnrollments(data, cbopt) → {Promise|undefined}

- - - - - -
-

Get a list of Guardian enrollments.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
data - - -Object - - - - - - - - - - -

The user data object.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
-  console.log(enrollments);
-});
- -
- -
- - -
- - - - - - - - - -
-

Link the user with another account.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
userId - - -String - - - - - - - - - - -

ID of the primary user.

- -
params - - -Object - - - - - - - - - - -

Secondary user data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
user_id - - -String - - - - -

ID of the user to be linked.

- -
connection_id - - -String - - - - -

ID of the connection to be used.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var userId = 'USER_ID';
-var params = {
-  user_id: 'OTHER_USER_ID',
-  connection_id: 'CONNECTION_ID'
-};
-
-management.users.link(userId, params, function (err, user) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Users linked.
-});
- -
- -
- - -
- - - -

logs(params, cbopt) → {Promise|undefined}

- - - - - -
-

Get user's log events.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Get logs data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

User id.

- -
per_page - - -Number - - - - -

Number of results per page.

- -
page - - -Number - - - - -

Page number, zero indexed.

- -
sort - - -String - - - - -

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

- -
include_totals - - -Boolean - - - - -

true if a query summary must be included in the result, false otherwise. Default false;

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };
-
-management.users.logs(params, function (err, logs) {
-  if (err) {
-    // Handle error.
-  }
-
-  console.log(logs);
-});
- -
- -
- - -
- - - -

regenerateRecoveryCode(params, cbopt) → {Promise|undefined}

- - - - - -
-

Generate new Guardian recovery code.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Get logs data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

User id.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
management.users.regenerateRecoveryCode("USER_ID", function (err, result) {
-  console.log(result.recovery_code);
-});
- -
- -
- - -
- - - - - - - - - -
-

Unlink the given accounts.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

Linked users data.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

Primary user ID.

- -
provider - - -String - - - - -

Identity provider in use.

- -
user_id - - -String - - - - -

Secondary user ID.

- -
- - -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function.

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };
-
-management.users.unlink(params, function (err, user) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Users accounts unlinked.
-});
- -
- -
- - -
- - - -

update(params, data, cbopt) → {Promise|undefined}

- - - - - -
-

Update a user by its id.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

The user parameters.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
data - - -Object - - - - - - - - - - -

New user data.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = { id: USER_ID };
-
-management.users.update(params, data, function (err, user) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Updated user.
-  console.log(user);
-});
- -
- -
- - -
- - - -

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

- - - - - -
-

Update the app metadata.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

The user data object..

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
metadata - - -Object - - - - - - - - - - -

New app metadata.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = { id: USER_ID };
-var metadata = {
-  foo: 'bar'
-};
-
-management.users.updateAppMetadata(params, metadata, function (err, user) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Updated user.
-  console.log(user);
-});
- -
- -
- - -
- - - -

updateUserMetadata(params, metadata, cbopt) → {Promise|undefined}

- - - - - -
-

Update the user metadata.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDescription
params - - -Object - - - - - - - - - - -

The user data object..

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -String - - - - -

The user id.

- -
- - -
metadata - - -Object - - - - - - - - - - -

New user metadata.

- -
cb - - -function - - - - - - <optional>
- - - - - -
-

Callback function

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -Promise -| - -undefined - - -
-
- - - -
- - - -
-
Example
- -
var params = { id: USER_ID };
-var metadata = {
-  address: '123th Node.js Street'
-};
-
-management.users.updateUserMetadata(params, metadata, function (err, user) {
-  if (err) {
-    // Handle error.
-  }
-
-  // Updated user.
-  console.log(user);
-});
- -
- -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-management.html b/docs/module-management.html deleted file mode 100644 index 24524f386..000000000 --- a/docs/module-management.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - management - Documentation - - - - - - - - - - - - - - - - - -
- -

management

- - - - - - - -
- -
- - - -
- -
-
- - - - - -
- - - - - - -

Classes

- -
-
BlacklistedTokensManager
-
- -
ClientGrantsManager
-
- -
ClientsManager
-
- -
ConnectionsManager
-
- -
CustomDomainsManager
-
- -
DeviceCredentialsManager
-
- -
EmailProviderManager
-
- -
EmailTemplatesManager
-
- -
GuardianManager
-
- -
JobsManager
-
- -
LogsManager
-
- -
ManagementClient
-
- -
ManagementTokenProvider
-
- -
ResourceServersManager
-
- -
RetryRestClient
-
- -
RulesConfigsManager
-
- -
RulesManager
-
- -
StatsManager
-
- -
TenantManager
-
- -
TicketsManager
-
- -
UsersManager
-
-
- - - - - - - - - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/module-utils.html b/docs/module-utils.html deleted file mode 100644 index c703086b0..000000000 --- a/docs/module-utils.html +++ /dev/null @@ -1,348 +0,0 @@ - - - - - - utils - Documentation - - - - - - - - - - - - - - - - - -
- -

utils

- - - - - - - -
- -
- - - -
- -
-
- - - - - -
- - - - - - - - - - - - - - -

Methods

- - - -
- - - -

(static) getRequestPromise()

- - - - - -
-

Perform a request with the given settings and return a promise that resolves -when the request is successfull and rejects when there's an error.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - -
- - - -

(static) jsonToBase64()

- - - - - -
-

Given a JSON string, convert it to its base64 representation.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - -
- - - -

(static) wrapPropertyMethod()

- - - - - -
-

Simple wrapper that, given a class, a property name and a method name, -creates a new method in the class that is a wrapper for the given -property method.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- -
- - - - -
- -
- -
- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. -
- - - - - \ No newline at end of file diff --git a/docs/utils.js.html b/docs/utils.js.html index e1092abfd..fe58afb5d 100644 --- a/docs/utils.js.html +++ b/docs/utils.js.html @@ -24,7 +24,8 @@
@@ -39,78 +40,65 @@

utils.js

-
var Promise = require('bluebird');
-var request = require('request');
-
-/**
- * @module utils
- */
-var utils = (module.exports = {});
+            
const pkg = require('../package.json');
 
 /**
  * Given a JSON string, convert it to its base64 representation.
  *
- * @method    jsonToBase64
- * @memberOf  module:utils
+ * @param {object} json Json data
+ * @returns {string}
  */
-utils.jsonToBase64 = function(json) {
-  var bytes = new Buffer(JSON.stringify(json));
-
-  return bytes
-    .toString('base64')
-    .replace(/\+/g, '-')
-    .replace(/\//g, '_')
-    .replace(/=+$/, '');
+const jsonToBase64 = (json) => {
+  const bytes = Buffer.from(JSON.stringify(json));
+
+  return bytes.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
 };
 
 /**
- * Simple wrapper that, given a class, a property name and a method name,
- * creates a new method in the class that is a wrapper for the given
- * property method.
+ * Return an object with information about the current client.
  *
- * @method    wrapPropertyMethod
- * @memberOf  module:utils
+ * @function    generateClientInfo
+ * @returns {object}   Object containing client information.
  */
-utils.wrapPropertyMethod = function(Parent, name, propertyMethod) {
-  var path = propertyMethod.split('.');
-  var property = path.shift();
-  var method = path.pop();
-
-  Object.defineProperty(Parent.prototype, name, {
-    enumerable: false,
-    get: function() {
-      return this[property][method].bind(this[property]);
-    }
-  });
+const generateClientInfo = () => ({
+  name: 'node-auth0',
+  version: pkg.version,
+  env: {
+    node: process.version.replace('v', ''),
+  },
+});
+
+const containsUnsafeChars = (s) => {
+  const safeChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*'(),%";
+  return !!s.split('').find((c) => !safeChars.includes(c));
 };
 
-/**
- * Perform a request with the given settings and return a promise that resolves
- * when the request is successfull and rejects when there's an error.
- *
- * @method    getRequestPromise
- * @memberOf  module:utils
- */
-utils.getRequestPromise = function(settings) {
-  return new Promise(function(resolve, reject) {
-    request(
-      {
-        url: settings.url,
-        method: settings.method,
-        body: settings.data,
-        json: typeof settings.data === 'object',
-        headers: settings.headers
-      },
-      function(err, res, body) {
-        if (err) {
-          reject(err);
-          return;
-        }
-
-        resolve(res.body);
-      }
-    );
-  });
+const maybeDecode = (url) => {
+  if (containsUnsafeChars(url)) {
+    return encodeURIComponent(url);
+  }
+  return url;
+};
+
+const sanitizeArguments = function (optionsCandidate, cbCandidate) {
+  if (optionsCandidate instanceof Function) {
+    return {
+      cb: optionsCandidate,
+      options: undefined,
+    };
+  }
+  return {
+    cb: cbCandidate,
+    options: optionsCandidate,
+  };
+};
+
+module.exports = {
+  jsonToBase64,
+  generateClientInfo,
+  containsUnsafeChars,
+  maybeDecode,
+  sanitizeArguments,
 };
 
@@ -124,7 +112,7 @@

utils.js


- Generated by JSDoc 3.5.5 on Mon Nov 12 2018 22:55:39 GMT-0200 (-02) using the Minami theme. + Generated by JSDoc 3.6.10 on Thu Dec 22 2022 21:12:57 GMT+0000 (Greenwich Mean Time) using the Minami theme.
diff --git a/examples/README.md b/examples/README.md index c8842fe86..e9d5a4ff3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,3 +1,3 @@ # Deprecation Notice -These samples have been deprecated. Please see the [**auth0-samples**](https://github.com/auth0-samples) org for the latest Auth0 and Node.js integration samples. \ No newline at end of file +These samples have been deprecated. Please see the [**auth0-samples**](https://github.com/auth0-samples) org for the latest Auth0 and Node.js integration samples. diff --git a/opslevel.yml b/opslevel.yml new file mode 100644 index 000000000..009a5ec0b --- /dev/null +++ b/opslevel.yml @@ -0,0 +1,6 @@ +--- +version: 1 +repository: + owner: dx_sdks + tier: + tags: diff --git a/package.json b/package.json index b91a85153..5396c24d2 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,31 @@ { "name": "auth0", - "version": "2.14.0", + "version": "3.0.1", "description": "SDK for Auth0 API v2", "main": "src/index.js", - "files": ["src"], + "sideEffects": false, + "files": [ + "src" + ], "scripts": { - "test": "mocha -R spec $(find ./test -name *.tests.js)", - "test:ci": - "istanbul cover _mocha --report lcovonly -R $(find ./test -name *.tests.js) -- -R mocha-multi --reporter-options spec=-,mocha-junit-reporter=-", - "test:coverage": "codecov", - "test:watch": "NODE_ENV=test mocha --timeout 5000 $(find ./test -name *.tests.js) --watch", + "test": "mocha --reporter spec './test/**/*.tests.js'", + "test:ci": "nyc npm run test -- --forbid-only --reporter mocha-junit-reporter", + "test:watch": "cross-env NODE_ENV=test mocha --timeout 5000 './test/**/*.tests.js' './test/*.tests.js' --watch", "jsdoc:generate": "jsdoc --configure .jsdoc.json --verbose", - "release:clean": "node scripts/cleanup.js", - "preversion": "node scripts/prepare.js", - "version": "node scripts/changelog.js && node scripts/jsdocs.js", - "postversion": "npm run release:clean", - "precommit": "pretty-quick --staged" + "precommit": "pretty-quick --staged", + "lint": "eslint ." }, "repository": { "type": "git", "url": "https://github.com/auth0/node-auth0" }, - "keywords": ["auth0", "api"], + "engines": { + "node": ">=14" + }, + "keywords": [ + "auth0", + "api" + ], "author": "Auth0", "license": "MIT", "bugs": { @@ -29,34 +33,38 @@ }, "homepage": "https://github.com/auth0/node-auth0", "dependencies": { - "bluebird": "^2.10.2", - "jsonwebtoken": "^8.3.0", - "jwks-rsa": "^1.3.0", - "lru-memoizer": "^1.11.1", - "object.assign": "^4.0.4", - "request": "^2.83.0", - "rest-facade": "^1.10.1", - "retry": "^0.10.1" + "axios": "^0.27.2", + "form-data": "^3.0.1", + "jsonwebtoken": "^9.0.0", + "jwks-rsa": "^3.0.0", + "lru-memoizer": "^2.1.4", + "rest-facade": "^1.16.3", + "retry": "^0.13.1" }, "devDependencies": { - "chai": "^2.2.0", - "codecov": "^2.2.0", - "husky": "^0.14.3", - "istanbul": "^0.4.0", - "jsdoc": "^3.5.5", - "json-loader": "^0.5.4", + "chai": "^4.2.0", + "cross-env": "^5.2.0", + "eslint": "^8.16.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-jsdoc": "^37.0.3", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-promise": "^6.0.0", + "husky": "^3.0.1", + "jsdoc": "^3.6.7", + "json-loader": "^0.5.7", + "jws": "^3.2.2", "minami": "^1.2.3", - "mocha": "^2.2.4", - "mocha-junit-reporter": "^1.13.0", - "mocha-multi": "^0.11.0", - "moment": "^2.18.1", - "nock": "^3.1.1", - "pem": "^1.13.1", - "prettier": "^1.12.0", - "pretty-quick": "^1.4.1", - "proxyquire": "^2.1.0", - "sinon": "^1.17.1", - "string-replace-webpack-plugin": "0.0.3", - "webpack": "^1.12.14" + "mocha": "^8.4.0", + "mocha-junit-reporter": "^2.0.0", + "nock": "^13.2.7", + "nyc": "^14.1.1", + "prettier": "2.4.1", + "pretty-quick": "^1.11.1", + "proxyquire": "^2.1.3", + "sinon": "^14.0.0", + "string-replace-webpack-plugin": "0.1.3", + "superagent-proxy": "^3.0.0", + "webpack": "^4.36.1" } } diff --git a/scripts/changelog.js b/scripts/changelog.js deleted file mode 100644 index 0998ded9c..000000000 --- a/scripts/changelog.js +++ /dev/null @@ -1,37 +0,0 @@ -if (process.platform === 'win32') { - console.error('Must be run on a Unix OS'); - process.exit(1); -} - -var library = require('../package.json'); -var fs = require('fs'); -var path = require('path'); -var execSync = require('child_process').execSync; -var moment = require('moment'); - -var tmp = fs.readFileSync('.release', 'utf-8'); -var currentVersion = fs.readFileSync(path.resolve(tmp, 'current-version'), 'utf-8'); -var changelogPath = path.resolve(tmp, 'CHANGELOG.md'); -var stream = fs.createWriteStream(changelogPath); - -var webtask = `https://webtask.it.auth0.com/api/run/wt-hernan-auth0_com-0/oss-changelog.js?webtask_no_cache=1&repo=node-auth0&milestone=v${library.version}`; -var command = `curl -f -s -H "Accept: text/markdown" "${webtask}"`; -var changes = execSync(command, {encoding: 'utf-8'}); -var previous = execSync('sed "s/\# Change Log//" CHANGELOG.md | sed \'1,2d\''); -stream.once('open', function(fd) { - stream.write('# Change Log'); - stream.write('\n'); - stream.write('\n'); - stream.write(`## [v${library.version}](https://github.com/auth0/node-auth0/tree/v${library.version}) (${moment().format('YYYY-MM-DD')})`); - stream.write('\n'); - stream.write(`[Full Changelog](https://github.com/auth0/node-auth0/compare/v${currentVersion}...v${library.version})`); - stream.write('\n'); - stream.write(changes); - stream.write('\n'); - stream.write(previous); - stream.end(); -}); -stream.once('close', function(fd) { - execSync(`mv ${changelogPath} CHANGELOG.md`, {stdio: 'inherit'}); - execSync('git add CHANGELOG.md', {stdio: 'inherit'}); -}); diff --git a/scripts/cleanup.js b/scripts/cleanup.js deleted file mode 100644 index 3c16beaf4..000000000 --- a/scripts/cleanup.js +++ /dev/null @@ -1,22 +0,0 @@ -if (process.platform === 'win32') { - console.error('Must be run on a Unix OS'); - process.exit(1); -} - -var execSync = require('child_process').execSync; -var fs = require('fs'); - -if (fs.existsSync('out')) { - execSync(`rm -r out`, {stdio: 'inherit'}); -} - -if (!fs.existsSync('.release')) { - console.log('No in progress release found'); - process.exit(0); -} -var tmp = fs.readFileSync('.release'); -if (fs.existsSync(tmp)) { - execSync(`rm -r ${tmp}`, {stdio: 'inherit'}); -} - -execSync(`rm -r .release`, {stdio: 'inherit'}); \ No newline at end of file diff --git a/scripts/jsdocs.js b/scripts/jsdocs.js index a77b5734e..e269a592a 100644 --- a/scripts/jsdocs.js +++ b/scripts/jsdocs.js @@ -1,15 +1,11 @@ -if (process.platform === 'win32') { - console.error('Must be run on a Unix OS'); - process.exit(1); -} - -var library = require('../package.json'); -var execSync = require('child_process').execSync; -var fs = require('fs'); +const fs = require('fs'); +const { execSync } = require('child_process'); +const library = require('../package.json'); -execSync('npm run jsdoc:generate', {stdio: 'inherit'}); +execSync('npm run jsdoc:generate', { stdio: 'inherit' }); if (fs.existsSync('docs')) { - execSync('rm -r docs', {stdio: 'inherit'}); + execSync('rm -r docs', { stdio: 'inherit' }); } -execSync(`mv out/${library.name}/${library.version}/ docs`, {stdio: 'inherit'}); -execSync('git add docs'); \ No newline at end of file +execSync(`mv out/auth0/${library.version}/ docs`, { + stdio: 'inherit', +}); diff --git a/scripts/prepare.js b/scripts/prepare.js deleted file mode 100644 index 32867ccb5..000000000 --- a/scripts/prepare.js +++ /dev/null @@ -1,19 +0,0 @@ -if (process.platform === 'win32') { - console.error('Must be run on a Unix OS'); - process.exit(1); -} - -var library = require('../package.json'); -var fs = require('fs'); -var path = require('path'); - -if (!fs.existsSync('.release')) { - var tmp = fs.mkdtempSync(`.release-tmp-`); - fs.writeFileSync('.release', tmp); -} else { - console.error('Found a pending release. Please run npm run release:clean'); - process.exit(1); -} - -var lastVersionFile = path.resolve(tmp, 'current-version'); -fs.writeFileSync(lastVersionFile, library.version); diff --git a/src/Auth0RestClient.js b/src/Auth0RestClient.js index fb44de7e5..88ff32958 100644 --- a/src/Auth0RestClient.js +++ b/src/Auth0RestClient.js @@ -1,72 +1,123 @@ -var RestClient = require('rest-facade').Client; -var Promise = require('bluebird'); -var ArgumentError = require('rest-facade').ArgumentError; +const RestClient = require('rest-facade').Client; +const { ArgumentError } = require('rest-facade'); -var Auth0RestClient = function(resourceUrl, options, provider) { - if (resourceUrl === null || resourceUrl === undefined) { - throw new ArgumentError('Must provide a Resource Url'); - } - - if ('string' !== typeof resourceUrl || resourceUrl.length === 0) { - throw new ArgumentError('The provided Resource Url is invalid'); - } +const utils = require('./utils'); +const { SanitizedError } = require('./errors'); - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide options'); - } +class Auth0RestClient { + constructor(resourceUrl, options, provider) { + if (resourceUrl === null || resourceUrl === undefined) { + throw new ArgumentError('Must provide a Resource Url'); + } - this.options = options; - this.provider = provider; - this.restClient = new RestClient(resourceUrl, options); + if ('string' !== typeof resourceUrl || resourceUrl.length === 0) { + throw new ArgumentError('The provided Resource Url is invalid'); + } - this.wrappedProvider = function(method, args) { - if (!this.provider) { - return this.restClient[method].apply(this.restClient, args); + if (options === null || typeof options !== 'object') { + throw new ArgumentError('Must provide options'); } - var callback; - if (args && args[args.length - 1] instanceof Function) { - callback = args[args.length - 1]; + options.errorCustomizer = options.errorCustomizer || SanitizedError; + options.errorFormatter = options.errorFormatter || { message: 'message', name: 'error' }; + + this.options = options; + this.provider = provider; + this.restClient = new RestClient(resourceUrl, options); + + this.wrappedProvider = function (method, args) { + if (!this.provider) { + return this._request(method, args); + } + + let callback; + if (args && args[args.length - 1] instanceof Function) { + callback = args[args.length - 1]; + } + + return this.provider + .getAccessToken() + .then((access_token) => { + this.restClient.options.headers['Authorization'] = `Bearer ${access_token}`; + return this._request(method, args); + }) + .catch((err) => { + if (callback) { + return callback(err); + } + throw err; + }); + }; + } + + _request(method, args) { + if (!this.options.includeResponseHeaders) { + return this.restClient[method](...args); } - var self = this; - return this.provider - .getAccessToken() - .then(function(access_token) { - self.options.headers['Authorization'] = 'Bearer ' + access_token; - return self.restClient[method].apply(self.restClient, args); - }) - .catch(function(err) { - if (callback) { - return callback(err); + let callback; + // Handle the case where the promise variant is called without any args + // client.get() -> client.get({}, callback) + if (!args || !args.length) { + args = [{}]; + } + // Handle the case where an undefined placeholder is defined for callback + // client.get(params, undefined) -> client.get(params, callback) + if (typeof args[args.length - 1] === 'undefined') { + args.pop(); + } + if (typeof args[args.length - 1] === 'function') { + callback = args.pop(); + } + return new Promise((resolve, reject) => { + this.restClient[method](...args, (err, data, headers) => { + const payload = { data, headers }; + if (err) { + if (callback) callback(err); + else reject(err); + return; } - return Promise.reject(err); + if (callback) callback(null, payload); + else resolve(payload); }); - }; -}; + }); + } -Auth0RestClient.prototype.getAll = function(/* [params], [callback] */) { - return this.wrappedProvider('getAll', arguments); -}; + getAll(...args) { + return this.wrappedProvider('getAll', args); + } -Auth0RestClient.prototype.get = function(/* [params], [callback] */) { - return this.wrappedProvider('get', arguments); -}; + get(params, callback) { + if (typeof params === 'object' && params.id) { + params.id = utils.maybeDecode(`${params.id}`); + } + return this.wrappedProvider('get', [...[params, callback].filter(Boolean)]); + } -Auth0RestClient.prototype.create = function(/* [params], [callback] */) { - return this.wrappedProvider('create', arguments); -}; + create(...args) { + return this.wrappedProvider('create', args); + } -Auth0RestClient.prototype.patch = function(/* [params], [callback] */) { - return this.wrappedProvider('patch', arguments); -}; + patch(params, ...restOfArgs) { + if (typeof params === 'object' && params.id) { + params.id = utils.maybeDecode(`${params.id}`); + } + return this.wrappedProvider('patch', [params, ...restOfArgs]); + } -Auth0RestClient.prototype.update = function(/* [params], [callback] */) { - return this.wrappedProvider('update', arguments); -}; + update(params, ...restOfArgs) { + if (typeof params === 'object' && params.id) { + params.id = utils.maybeDecode(`${params.id}`); + } + return this.wrappedProvider('update', [params, ...restOfArgs]); + } -Auth0RestClient.prototype.delete = function(/* [params], [callback] */) { - return this.wrappedProvider('delete', arguments); -}; + delete(params, ...restOfArgs) { + if (typeof params === 'object' && params.id) { + params.id = utils.maybeDecode(`${params.id}`); + } + return this.wrappedProvider('delete', [params, ...restOfArgs]); + } +} module.exports = Auth0RestClient; diff --git a/src/RetryRestClient.js b/src/RetryRestClient.js index 28ea9cf43..65f01b4a1 100644 --- a/src/RetryRestClient.js +++ b/src/RetryRestClient.js @@ -1,156 +1,105 @@ -var Promise = require('bluebird'); -var retry = require('retry'); -var ArgumentError = require('rest-facade').ArgumentError; -var assign = Object.assign || require('object.assign'); +const retry = require('retry'); +const { ArgumentError } = require('rest-facade'); -var DEFAULT_OPTIONS = { maxRetries: 10, enabled: true }; +const DEFAULT_OPTIONS = { + maxRetries: 3, + enabled: true, + randomize: true, +}; /** - * @class RetryRestClient * Wrapper Rest Client that adds Retry functionality when requests are failing due to rate limiting (status code 429). - * @constructor - * @memberOf module:management - * @param {Object} restClient RestClient. - * @param {Object} [options] Options for the RetryRestClient. - * @param {Object} [options.enabled:true] Enabled or Disable Retry Policy functionality. - * @param {Number} [options.maxRetries=10] The maximum amount of times to retry the operation. Default is 10. */ -var RetryRestClient = function(restClient, options) { - if (restClient === null || typeof restClient !== 'object') { - throw new ArgumentError('Must provide RestClient'); - } - - var params = assign({}, DEFAULT_OPTIONS, options); - - if (typeof params.enabled !== 'boolean') { - throw new ArgumentError('Must provide enabled boolean value'); - } - - if (typeof params.maxRetries !== 'number' || params.maxRetries <= 0) { - throw new ArgumentError('Must provide maxRetries as a positive number'); - } - - this.restClient = restClient; - this.maxRetries = params.maxRetries; - this.enabled = params.enabled; -}; - -RetryRestClient.prototype.getAll = function(/* [params], [callback] */) { - return this.invoke('getAll', arguments); -}; +class RetryRestClient { + /** + * @param {object} restClient RestClient. + * @param {object} [options] Options for the RetryRestClient. It includes all properties from https://github.com/tim-kos/node-retry#retryoperationoptions + * @param {object} [options.enabled=true] Enabled or Disable Retry Policy functionality. + * @param {number} [options.maxRetries=3] The maximum amount of times to retry the operation. + */ + constructor(restClient, options) { + if (restClient === null || typeof restClient !== 'object') { + throw new ArgumentError('Must provide RestClient'); + } -RetryRestClient.prototype.get = function(/* [params], [callback] */) { - return this.invoke('get', arguments); -}; + const params = Object.assign({}, DEFAULT_OPTIONS, options); -RetryRestClient.prototype.create = function(/* [params], [callback] */) { - return this.invoke('create', arguments); -}; + if (typeof params.enabled !== 'boolean') { + throw new ArgumentError('Must provide enabled boolean value'); + } -RetryRestClient.prototype.patch = function(/* [params], [callback] */) { - return this.invoke('patch', arguments); -}; + if (typeof params.maxRetries !== 'number' || params.maxRetries <= 0) { + throw new ArgumentError('Must provide maxRetries as a positive number'); + } -RetryRestClient.prototype.update = function(/* [params], [callback] */) { - return this.invoke('update', arguments); -}; + this.restClient = restClient; + this.enabled = params.enabled; + this.retryOptions = Object.assign({ retries: params.maxRetries }, params); + } -RetryRestClient.prototype.delete = function(/* [params], [callback] */) { - return this.invoke('delete', arguments); -}; + getAll(...args) { + return this.invoke('getAll', args); + } -RetryRestClient.prototype.invoke = function(method, args) { - var cb; - args = Array.prototype.slice.call(args); // convert array-like object to array. - if (args && args[args.length - 1] instanceof Function) { - cb = args[args.length - 1]; - args.pop(); // Remove the callback + get(...args) { + return this.invoke('get', args); } - var promise = this.handleRetry(method, args); + create(...args) { + return this.invoke('create', args); + } - if (cb instanceof Function) { - promise.then(cb.bind(null, null)).catch(cb); - return; + patch(...args) { + return this.invoke('patch', args); } - return promise; -}; + update(...args) { + return this.invoke('update', args); + } -RetryRestClient.prototype.handleRetry = function(method, args) { - if (!this.enabled) { - return this.restClient[method].apply(this.restClient, args); + delete(...args) { + return this.invoke('delete', args); } - var retryOptions = { - retries: this.maxRetries, - factor: 1, - minTimeout: 1, // retry immediate, use custom logic to control this. - randomize: false - }; - - var self = this; - var promise = new Promise(function(resolve, reject) { - var operation = retry.operation(retryOptions); - - operation.attempt(function() { - self.restClient[method] - .apply(self.restClient, args) - .then(function(body) { - resolve(body); - }) - .catch(function(err) { - self.invokeRetry(err, operation, reject); - }); - }); - }); + invoke(method, args) { + let cb; + if (args && args[args.length - 1] instanceof Function) { + cb = args[args.length - 1]; + args.pop(); // Remove the callback + } - return promise; -}; + const promise = this.handleRetry(method, args); -RetryRestClient.prototype.invokeRetry = function(err, operation, reject) { - var ratelimits = this.extractRatelimits(err); - if (ratelimits) { - var delay = ratelimits.reset * 1000 - new Date().getTime(); - if (delay > 0) { - this.retryWithDelay(delay, operation, err, reject); - } else { - this.retryWithImmediate(operation, err, reject); + if (cb instanceof Function) { + promise.then(cb.bind(null, null)).catch(cb); + return; } - } else { - reject(err); - } -}; -RetryRestClient.prototype.extractRatelimits = function(err) { - if (err && err.statusCode === 429 && err.originalError && err.originalError.response) { - var headers = err.originalError.response.header; - if (headers && headers['x-ratelimit-limit']) { - return { - limit: headers['x-ratelimit-limit'], - remaining: headers['x-ratelimit-remaining'], - reset: headers['x-ratelimit-reset'] - }; - } + return promise; } - return; -}; + handleRetry(method, args) { + if (!this.enabled) { + return this.restClient[method](...args); + } -RetryRestClient.prototype.retryWithImmediate = function(operation, err, reject) { - if (operation.retry(err)) { - return; + return new Promise((resolve, reject) => { + const operation = retry.operation(this.retryOptions); + + operation.attempt(() => { + this.restClient[method](...args) + .then((body) => { + resolve(body); + }) + .catch((err) => { + if (err && err.statusCode === 429 && operation.retry(err)) { + return; + } + reject(err); + }); + }); + }); } - reject(err); -}; - -RetryRestClient.prototype.retryWithDelay = function(delay, operation, err, reject) { - setTimeout(() => { - if (operation.retry(err)) { - return; - } - reject(err); - }, delay); -}; +} module.exports = RetryRestClient; diff --git a/src/auth/DatabaseAuthenticator.js b/src/auth/DatabaseAuthenticator.js index 96a9e18ee..cebb038a8 100644 --- a/src/auth/DatabaseAuthenticator.js +++ b/src/auth/DatabaseAuthenticator.js @@ -1,294 +1,280 @@ -var extend = require('util')._extend; - -var ArgumentError = require('rest-facade').ArgumentError; -var RestClient = require('rest-facade').Client; +const { ArgumentError } = require('rest-facade'); +const RestClient = require('rest-facade').Client; /** - * @class * Abstracts the sign-in, sign-up and change-password processes for Database & * Active Directory authentication services. - * @constructor - * @memberOf module:auth - * - * @param {Object} options Authenticator options. - * @param {String} options.baseUrl The auth0 account URL. - * @param {String} [options.clientId] Default client ID. - * @param {OAuthAuthenticator} oauth OAuthAuthenticator instance. */ -var DatabaseAuthenticator = function(options, oauth) { - if (!options) { - throw new ArgumentError('Missing authenticator options'); - } +class DatabaseAuthenticator { + /** + * @param {object} options Authenticator options. + * @param {string} options.baseUrl The auth0 account URL. + * @param {string} [options.clientId] Default client ID. + * @param {OAuthAuthenticator} oauth OAuthAuthenticator instance. + */ + constructor(options, oauth) { + if (!options) { + throw new ArgumentError('Missing authenticator options'); + } - if (typeof options !== 'object') { - throw new ArgumentError('The authenticator options must be an object'); + if (typeof options !== 'object') { + throw new ArgumentError('The authenticator options must be an object'); + } + + /** + * Options object for the Rest Client instance. + * + * @type {object} + */ + const clientOptions = { + errorFormatter: { message: 'message', name: 'error' }, + headers: options.headers, + }; + + this.oauth = oauth; + this.dbConnections = new RestClient(`${options.baseUrl}/dbconnections/:type`, clientOptions); + this.clientId = options.clientId; } /** - * Options object for the Rest Client instace. + * Sign in using a database or active directory service. + * + * @example + * Given the user credentials and the connection specified, it will do the + * authentication on the provider and return a JSON with the `access_token` + * and `id_token`. Find more information about the structure of the data + * object in the + * API docs. + * * - * @type {Object} + * var data = { + * username: '{USERNAME}', + * password: '{PASSWORD}', + * connection: 'Username-Password-Authentication' // Optional field. + * }; + * + * auth0.database.signIn(data, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.username Username. + * @param {string} userData.password User password. + * @param {string} userData.connection Identity provider in use. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' } - }; + signIn(userData, cb) { + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } - this.oauth = oauth; - this.dbConnections = new RestClient(options.baseUrl + '/dbconnections/:type', clientOptions); - this.clientId = options.clientId; -}; + const data = { + connection: 'Username-Password-Authentication', + ...userData, + }; -/** - * Sign in using a database or active directory service. - * @method signIn - * @memberOf module:auth.DatabaseAuthenticator.prototype - * - * @example - * Given the user credentials and the connection specified, it will do the - * authentication on the provider and return a JSON with the `access_token` - * and `id_token`. Find more information about the structure of the data - * object in the - * API docs. - * - * - * var data = { - * username: '{USERNAME}', - * password: '{PASSWORD}', - * connection: 'Username-Password-Authentication' // Optional field. - * }; - * - * auth0.database.signIn(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} data User credentials object. - * @param {String} data.username Username. - * @param {String} data.password User password. - * @param {String} data.connection Identity provider in use. - * @param {Function} [cb] Method callback. - * - * @return {Promise|undefined} - */ -DatabaseAuthenticator.prototype.signIn = function(userData, cb) { - var defaultFields = { - connection: 'Username-Password-Authentication' - }; - var data = extend(defaultFields, userData); - - if (!userData || typeof userData !== 'object') { - throw new ArgumentError('Missing user data object'); - } + if (typeof data.username !== 'string' || data.username.trim().length === 0) { + throw new ArgumentError('username field is required'); + } - if (typeof data.username !== 'string' || data.username.trim().length === 0) { - throw new ArgumentError('username field is required'); - } + if (typeof data.password !== 'string' || data.password.trim().length === 0) { + throw new ArgumentError('password field is required'); + } - if (typeof data.password !== 'string' || data.password.trim().length === 0) { - throw new ArgumentError('password field is required'); + return this.oauth.signIn(data, cb); } - return this.oauth.signIn(data, cb); -}; + /** + * Sign up using a database or active directory service. + * + * @example + * Given the user credentials, the connection specified and (optionally) the + * client ID, it will create a new user. Find more information in the + * + * API Docs. + * + * + * var data = { + * email: '{EMAIL}', + * password: '{PASSWORD}', + * connection: 'Username-Password-Authentication' // Optional field. + * }; + * + * auth0.database.signUp(data, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.email User email address. + * @param {string} userData.password User password. + * @param {string} userData.connection Identity provider in use. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + signUp(userData, cb) { + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } -/** - * Sign up using a database or active directory service. - * @method signUp - * @memberOf module:auth.DatabaseAuthenticator.prototype - * - * @example - * Given the user credentials, the connection specified and (optionally) the - * client ID, it will create a new user. Find more information in the - * - * API Docs. - * - * - * var data = { - * email: '{EMAIL}', - * password: '{PASSWORD}', - * connection: 'Username-Password-Authentication' // Optional field. - * }; - * - * auth0.database.signUp(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} data User credentials object. - * @param {String} data.email User email address. - * @param {String} data.password User password. - * @param {Stinrg} data.connection Identity provider in use. - * @param {Function} [cb] Method callback. - * - * @return {Promise|undefined} - */ -DatabaseAuthenticator.prototype.signUp = function(userData, cb) { - var params = { - type: 'signup' - }; - var defaultFields = { - client_id: this.clientId - }; - var data = extend(defaultFields, userData); - - if (!userData || typeof userData !== 'object') { - throw new ArgumentError('Missing user data object'); - } + const data = { + client_id: this.clientId, + ...userData, + }; - if (typeof data.email !== 'string' || data.email.trim().length === 0) { - throw new ArgumentError('email field is required'); - } + if (typeof data.email !== 'string' || data.email.trim().length === 0) { + throw new ArgumentError('email field is required'); + } - if (typeof data.password !== 'string' || data.password.trim().length === 0) { - throw new ArgumentError('password field is required'); - } + if (typeof data.password !== 'string' || data.password.trim().length === 0) { + throw new ArgumentError('password field is required'); + } - if (typeof data.connection !== 'string' || data.connection.trim().length === 0) { - throw new ArgumentError('connection field is required'); - } + if (typeof data.connection !== 'string' || data.connection.trim().length === 0) { + throw new ArgumentError('connection field is required'); + } - if (cb && cb instanceof Function) { - return this.dbConnections.create(params, data, cb); - } + const params = { + type: 'signup', + }; - return this.dbConnections.create(params, data); -}; + if (cb && cb instanceof Function) { + return this.dbConnections.create(params, data, cb); + } -/** - * Change password using a database or active directory service. - * - * @method changePassword - * @memberOf module:auth.DatabaseAuthenticator.prototype - * - * @example - * Given the user email, the connection specified and the new password to - * use, Auth0 will send a forgot password email. Once the user clicks on the - * confirm password change link, the new password specified in this POST will - * be set to this user. Find more information in the - * + * API Docs. + * + * + * var data = { + * email: '{EMAIL}', + * password: '{PASSWORD}', + * connection: 'Username-Password-Authentication' + * }; + * + * auth0.database.changePassword(data, function (err, message) { + * if (err) { + * // Handle error. + * } + * + * console.log(message); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.email User email address. + * @param {string} userData.password New password. + * @param {string} userData.connection Identity provider in use. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + changePassword(userData, cb) { + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } - if (typeof data.password !== 'string' || data.password.trim().length === 0) { - throw new ArgumentError('password field is required'); - } + const data = { + client_id: this.clientId, + ...userData, + }; - if (typeof data.connection !== 'string' || data.connection.trim().length === 0) { - throw new ArgumentError('connection field is required'); - } + if (typeof data.email !== 'string' || data.email.trim().length === 0) { + throw new ArgumentError('email field is required'); + } - if (cb && cb instanceof Function) { - return this.dbConnections.create(params, data, cb); - } + if (typeof data.password !== 'string' || data.password.trim().length === 0) { + throw new ArgumentError('password field is required'); + } - return this.dbConnections.create(params, data); -}; + if (typeof data.connection !== 'string' || data.connection.trim().length === 0) { + throw new ArgumentError('connection field is required'); + } -/** - * Request a change password email using a database or active directory service. - * - * @method requestChangePasswordEmail - * @memberOf module:auth.DatabaseAuthenticator.prototype - * - * @example - * Given the user email, the connection specified, Auth0 will send a change - * password email. once the user clicks on the confirm password change link, - * the new password specified in this POST will be set to this user. Find more - * information in the + * API Docs. + * + * + * var data = { + * email: '{EMAIL}', + * connection: 'Username-Password-Authentication', + * client_id: 'OS1VzKTVjizL0VCc9Hx2ae2aTPXWy6BD' + * }; + * + * auth0.database.requestChangePasswordEmail(data, function (err, message) { + * if (err) { + * // Handle error. + * } + * + * console.log(message); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.email User email address. + * @param {string} userData.connection Identity provider in use. + * @param {string} userData.client_id Client ID of the Application requesting the password change, to be included in the email template. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + requestChangePasswordEmail(userData, cb) { + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } - return this.dbConnections.create(params, data); -}; + const data = { + client_id: this.clientId, + ...userData, + }; + + if (typeof data.email !== 'string' || data.email.trim().length === 0) { + throw new ArgumentError('email field is required'); + } + + if (typeof data.connection !== 'string' || data.connection.trim().length === 0) { + throw new ArgumentError('connection field is required'); + } + + const params = { + type: 'change_password', + }; + + if (cb && cb instanceof Function) { + return this.dbConnections.create(params, data, cb); + } + + return this.dbConnections.create(params, data); + } +} module.exports = DatabaseAuthenticator; diff --git a/src/auth/OAUthWithIDTokenValidation.js b/src/auth/OAUthWithIDTokenValidation.js index b9833f948..5c716327f 100644 --- a/src/auth/OAUthWithIDTokenValidation.js +++ b/src/auth/OAUthWithIDTokenValidation.js @@ -1,97 +1,124 @@ -var jwt = require('jsonwebtoken'); -var jwksClient = require('jwks-rsa'); -var Promise = require('bluebird'); +const jwt = require('jsonwebtoken'); +const jwksClient = require('jwks-rsa'); +const { ArgumentError } = require('rest-facade'); +const validateIdToken = require('./idToken').validate; -var ArgumentError = require('rest-facade').ArgumentError; +const HS256_IGNORE_VALIDATION_MESSAGE = + 'Validation of `id_token` requires a `clientSecret` when using the HS256 algorithm. To ensure tokens are validated, please switch the signing algorithm to RS256 or provide a `clientSecret` in the constructor.'; /** - * @class * Abstracts the `oauth.create` method with additional id_token validation - * @constructor - * @memberOf module:auth - * - * @param {Object} oauth An instance of @type {OAuthAuthenticator} - * @param {Object} options Authenticator options. - * @param {String} options.domain AuthenticationClient server domain - * @param {String} [options.clientId] Default client ID. - * @param {String} [options.clientSecret] Default client Secret. - * @param {String} [options.supportedAlgorithms] Algorithms that your application expects to receive */ -var OAUthWithIDTokenValidation = function(oauth, options) { - if (!oauth) { - throw new ArgumentError('Missing OAuthAuthenticator param'); - } +class OAUthWithIDTokenValidation { + /** + * @param {object} oauth An instance of @type {OAuthAuthenticator} + * @param {object} options Authenticator options. + * @param {string} options.domain AuthenticationClient server domain + * @param {string} [options.clientId] Default client ID. + * @param {string} [options.clientSecret] Default client Secret. + * @param {string} [options.supportedAlgorithms] Algorithms that your application expects to receive + * @param {boolean} [options.__bypassIdTokenValidation] Whether the id_token should be validated or not + */ + constructor(oauth, options) { + if (!oauth) { + throw new ArgumentError('Missing OAuthAuthenticator param'); + } - if (!options) { - throw new ArgumentError('Missing authenticator options'); - } + if (!options) { + throw new ArgumentError('Missing authenticator options'); + } - if (typeof options !== 'object') { - throw new ArgumentError('The authenticator options must be an object'); - } + if (typeof options !== 'object') { + throw new ArgumentError('The authenticator options must be an object'); + } - this.oauth = oauth; - this.clientId = options.clientId; - this.clientSecret = options.clientSecret; - this.domain = options.domain; - this.supportedAlgorithms = options.supportedAlgorithms || ['HS256', 'RS256']; - this._jwksClient = jwksClient({ - jwksUri: 'https://' + options.domain + '/.well-known/jwks.json' - }); -}; + this.oauth = oauth; + this.__bypassIdTokenValidation = options.__bypassIdTokenValidation; + this.clientId = options.clientId; + this.clientSecret = options.clientSecret; + this.domain = options.domain; + this.supportedAlgorithms = options.supportedAlgorithms || ['HS256', 'RS256']; + this._jwksClient = jwksClient({ + jwksUri: `https://${options.domain}/.well-known/jwks.json`, + }); + } -/** - * Creates an oauth request and validates the id_token (if any) - * - * @method create - * @memberOf module:auth.OAuthWithIDTokenValidation.prototype - * - * @param {Object} params OAuth parameters that are passed through - * @param {Object} data Custom parameters sent to the OAuth endpoint - * @param {Function} [callback] Callback function - * - * @return {Promise|undefined} - */ -OAUthWithIDTokenValidation.prototype.create = function(params, data, cb) { - const createAndValidate = this.oauth.create(params, data).then(r => { - var _this = this; - if (r.id_token) { - function getKey(header, callback) { - if (header.alg === 'HS256') { - return callback(null, Buffer.from(_this.clientSecret, 'base64')); + /** + * Creates an oauth request and validates the id_token (if any) + * + * @param {object} params OAuth parameters that are passed through + * @param {object} data Custom parameters sent to the OAuth endpoint + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + create(params, data, cb) { + const _this = this; + function getKey(header, callback) { + if (header.alg === 'HS256') { + if (!_this.clientSecret) { + return callback({ message: HS256_IGNORE_VALIDATION_MESSAGE }); } - _this._jwksClient.getSigningKey(header.kid, function(err, key) { - if (err) { - return callback(err); - } - var signingKey = key.publicKey || key.rsaPublicKey; - return callback(null, signingKey); - }); + return callback(null, Buffer.from(_this.clientSecret, 'base64')); + } + _this._jwksClient.getSigningKey(header.kid, (err, key) => { + if (err) { + return callback(err); + } + const signingKey = key.publicKey || key.rsaPublicKey; + return callback(null, signingKey); + }); + } + const createAndValidate = this.oauth.create(params, data).then((r) => { + if (_this.__bypassIdTokenValidation) { + return r; } - return new Promise((res, rej) => { - jwt.verify( - r.id_token, - getKey, - { + + if (r.id_token) { + return new Promise((resolve, reject) => { + const options = { algorithms: this.supportedAlgorithms, audience: this.clientId, - issuer: 'https://' + this.domain + '/' - }, - function(err, payload) { + issuer: `https://${this.domain}/`, + }; + + if (data.organization) { + options.organization = data.organization; + } + + if (data.nonce) { + options.nonce = data.nonce; + } + + if (data.maxAge) { + options.maxAge = data.maxAge; + } + + jwt.verify(r.id_token, getKey, options, (err) => { if (err) { - return rej(err); + if (err.message && err.message.includes(HS256_IGNORE_VALIDATION_MESSAGE)) { + console.warn(HS256_IGNORE_VALIDATION_MESSAGE); + } else { + return reject(err); + } } - return res(r); - } - ); - }); + + try { + validateIdToken(r.id_token, options); + } catch (idTokenError) { + return reject(idTokenError); + } + + return resolve(r); + }); + }); + } + return r; + }); + if (!cb) { + return createAndValidate; } - return r; - }); - if (!cb) { - return createAndValidate; + createAndValidate.then((r) => cb(null, r)).catch((e) => cb(e)); } - createAndValidate.then(r => cb(null, r)).catch(e => cb(e)); -}; +} module.exports = OAUthWithIDTokenValidation; diff --git a/src/auth/OAuthAuthenticator.js b/src/auth/OAuthAuthenticator.js index d8df93582..f3f981003 100644 --- a/src/auth/OAuthAuthenticator.js +++ b/src/auth/OAuthAuthenticator.js @@ -1,373 +1,391 @@ -var extend = require('util')._extend; - -var ArgumentError = require('rest-facade').ArgumentError; -var RestClient = require('rest-facade').Client; - -var OAUthWithIDTokenValidation = require('./OAUthWithIDTokenValidation'); +const { sanitizeArguments } = require('../utils'); +const { ArgumentError } = require('rest-facade'); +const RestClient = require('rest-facade').Client; +const { SanitizedError } = require('../errors'); +const OAUthWithIDTokenValidation = require('./OAUthWithIDTokenValidation'); + +function getParamsFromOptions(options) { + const params = {}; + if (!options || typeof options !== 'object') { + return params; + } + if (options.forwardedFor) { + params._requestCustomizer = function (req) { + req.set('auth0-forwarded-for', options.forwardedFor); + }; + } + if (options.type) { + params.type = options.type; + } + return params; +} /** - * @class * Abstracts the sign-in, sign-up and change-password processes for Database & * Active Directory authentication services. - * @constructor - * @memberOf module:auth - * - * @param {Object} options Authenticator options. - * @param {String} options.baseUrl The Auth0 account URL. - * @param {String} options.domain AuthenticationClient server domain - * @param {String} [options.clientId] Default client ID. - * @param {String} [options.clientSecret] Default client Secret. */ -var OAuthAuthenticator = function(options) { - if (!options) { - throw new ArgumentError('Missing authenticator options'); - } - - if (typeof options !== 'object') { - throw new ArgumentError('The authenticator options must be an object'); +class OAuthAuthenticator { + /** + * @param {object} options Authenticator options. + * @param {string} options.baseUrl The Auth0 account URL. + * @param {string} options.domain AuthenticationClient server domain + * @param {string} [options.clientId] Default client ID. + * @param {string} [options.clientSecret] Default client Secret. + * @param {boolean} [options.__bypassIdTokenValidation] Whether the id_token should be validated or not + */ + constructor(options) { + if (!options) { + throw new ArgumentError('Missing authenticator options'); + } + + if (typeof options !== 'object') { + throw new ArgumentError('The authenticator options must be an object'); + } + + /** + * Options object for the Rest Client instance. + * + * @type {object} + */ + const clientOptions = { + errorCustomizer: SanitizedError, + errorFormatter: { message: 'message', name: 'error' }, + headers: options.headers, + }; + + this.oauth = new RestClient(`${options.baseUrl}/oauth/:type`, clientOptions); + this.oauthWithIDTokenValidation = new OAUthWithIDTokenValidation(this.oauth, options); + this.clientId = options.clientId; + this.clientSecret = options.clientSecret; } /** - * Options object for the Rest Client instace. + * Sign in using a username and password. + * + * @example + * Given the user's credentials and the connection specified, it + * will return a JSON with the access_token and id_token. + * More information in the * - * @type {Object} + * + * API Docs + * . + * + * + * var data = { + * client_id: '{CLIENT_ID}', // Optional field. + * username: '{USERNAME}', + * password: '{PASSWORD}', + * connection: '{CONNECTION_NAME}', + * scope: 'openid' // Optional field. + * }; + * + * auth0.oauth.signIn(data, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.username Username. + * @param {string} userData.password User password. + * @param {string} userData.connection The identity provider in use. + * @param {object} [options] Additional options. + * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header + * @param {Function} cb Callback + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' } - }; - - this.oauth = new RestClient(options.baseUrl + '/oauth/:type', clientOptions); - this.oauthWithIDTokenValidation = new OAUthWithIDTokenValidation(this.oauth, options); - this.clientId = options.clientId; - this.clientSecret = options.clientSecret; -}; - -/** - * Sign in using a username and password. - * - * @method signIn - * @memberOf module:auth.OAuthAuthenticator.prototype - * - * @example - * Given the user's credentials and the connection specified, it - * will return a JSON with the access_token and id_token. - * More information in the - * - * API Docs - * . - * - * - * var data = { - * client_id: '{CLIENT_ID}', // Optional field. - * username: '{USERNAME}', - * password: '{PASSWORD}', - * connection: '{CONNECTION_NAME}', - * scope: 'openid' // Optional field. - * }; - * - * auth0.oauth.signIn(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} userData User credentials object. - * @param {String} userData.username Username. - * @param {String} userData.password User password. - * @param {String} userData.connection The identity provider in use. - * - * @return {Promise|undefined} - */ -OAuthAuthenticator.prototype.signIn = function(userData, cb) { - var params = { - type: 'ro' - }; - var defaultFields = { - client_id: this.clientId, - grant_type: 'password', - scope: 'openid' - }; - var data = extend(defaultFields, userData); - - if (!userData || typeof userData !== 'object') { - throw new ArgumentError('Missing user data object'); - } - - if (typeof data.connection !== 'string' || data.connection.split().length === 0) { - throw new ArgumentError('connection field is required'); - } - - if (cb && cb instanceof Function) { - return this.oauthWithIDTokenValidation.create(params, data, cb); - } - - return this.oauthWithIDTokenValidation.create(params, data); -}; - -/** - * Sign in using a username and password - * - * @method passwordGrant - * @memberOf module:auth.OAuthAuthenticator.prototype - * - * @example - * Given the user's credentials perform the OAuth password grant - * or Password Realm grant if a realm is provided, - * it will return a JSON with the access_token and id_token. - * More information in the - * - * API Docs - * . - * - * - * var data = { - * client_id: '{CLIENT_ID}', // Optional field. - * username: '{USERNAME}', - * password: '{PASSWORD}', - * realm: '{CONNECTION_NAME}', // Optional field. - * scope: 'openid' // Optional field. - * }; - * - * auth0.oauth.passwordGrant(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} userData User credentials object. - * @param {String} userData.username Username. - * @param {String} userData.password User password. - * @param {String} [userData.realm] Name of the realm to use to authenticate or the connection name - * - * @return {Promise|undefined} - */ -OAuthAuthenticator.prototype.passwordGrant = function(userData, cb) { - var params = { - type: 'token' - }; - var defaultFields = { - client_id: this.clientId, - client_secret: this.clientSecret, - grant_type: 'password' - }; - var data = extend(defaultFields, userData); - - if (!userData || typeof userData !== 'object') { - throw new ArgumentError('Missing user data object'); - } - - if (typeof data.username !== 'string' || data.username.split().length === 0) { - throw new ArgumentError('username field is required'); - } - - if (typeof data.password !== 'string' || data.password.split().length === 0) { - throw new ArgumentError('password field is required'); - } - - if (typeof data.realm === 'string' && data.realm.split().length !== 0) { - data.grant_type = 'http://auth0.com/oauth/grant-type/password-realm'; - } - - if (cb && cb instanceof Function) { - return this.oauthWithIDTokenValidation.create(params, data, cb); - } - - return this.oauthWithIDTokenValidation.create(params, data); -}; - -/** - * Sign in using a refresh token - * - * @method refreshToken - * @memberOf module:auth.OAuthAuthenticator.prototype - * - * @example - * Given a refresh token from a previous authentication request - * it will return a JSON with the access_token and id_token. - * More information in the - * - * API Docs - * . - * - * - * var data = { - * client_id: '{CLIENT_ID}', // Optional field. - * refresh_token: '{REFRESH_TOKEN}', - * }; - * - * auth0.oauth.refreshToken(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} userData User credentials object. - * @param {String} userData.refresh_token Refresh token. - * - * @return {Promise|undefined} - */ -OAuthAuthenticator.prototype.refreshToken = function(userData, cb) { - var params = { - type: 'token' - }; - var defaultFields = { - client_id: this.clientId, - grant_type: 'refresh_token' - }; - var data = extend(defaultFields, userData); - if (!userData || typeof userData !== 'object') { - throw new ArgumentError('Missing user data object'); - } - if (typeof data.refresh_token !== 'string' || data.refresh_token.split().length === 0) { - throw new ArgumentError('refresh_token is required'); - } - if (cb && cb instanceof Function) { - return this.oauthWithIDTokenValidation.create(params, data, cb); + signIn(userData, options, cb) { + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } + + const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb); + const params = { + type: 'ro', + ...getParamsFromOptions(sanitizedOptions), + }; + + const data = { + client_id: this.clientId, + grant_type: 'password', + scope: 'openid', + ...userData, + }; + + if ( + params.type === 'ro' && + (typeof data.connection !== 'string' || data.connection.split().length === 0) + ) { + throw new ArgumentError('connection field is required'); + } + + if (sanitizedCb && sanitizedCb instanceof Function) { + return this.oauthWithIDTokenValidation.create(params, data, sanitizedCb); + } + + return this.oauthWithIDTokenValidation.create(params, data); } - return this.oauthWithIDTokenValidation.create(params, data); -}; -/** - * Sign in using a social provider access token. - * - * @method socialSignIn - * @memberOf module:auth.OAuthAuthenticator.prototype - * - * @param {Object} data User credentials object. - * @param {String} data.access_token User access token. - * @param {String} data.connection Identity provider. - * - * @return {Promise|undefined} - */ -OAuthAuthenticator.prototype.socialSignIn = function(data, cb) { - var params = { - type: 'access_token' - }; - - if (typeof data !== 'object') { - throw new ArgumentError('Missing user credential objects'); - } - - if (typeof data.access_token !== 'string' || data.access_token.trim().length === 0) { - throw new ArgumentError('access_token field is required'); - } - - if (typeof data.connection !== 'string' || data.connection.trim().length === 0) { - throw new ArgumentError('connection field is required'); + /** + * Sign in using a username and password + * + * @example + * Given the user's credentials perform the OAuth password grant + * or Password Realm grant if a realm is provided, + * it will return a JSON with the access_token and id_token. + * + * More information in the + * + * API Docs + * . + * + * + * var data = { + * client_id: '{CLIENT_ID}', // Optional field. + * username: '{USERNAME}', + * password: '{PASSWORD}', + * realm: '{CONNECTION_NAME}', // Optional field. + * scope: 'openid' // Optional field. + * }; + * + * auth0.oauth.passwordGrant(data, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.username Username. + * @param {string} userData.password User password. + * @param {string} [userData.realm] Name of the realm to use to authenticate or the connection name + * @param {object} [options] Additional options. + * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header + * @param {Function} cb Callback + * @returns {Promise|undefined} + */ + passwordGrant(userData, options, cb) { + const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb); + + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } + + const data = { + client_id: this.clientId, + client_secret: this.clientSecret, + grant_type: 'password', + ...userData, + }; + + if (typeof data.username !== 'string' || data.username.split().length === 0) { + throw new ArgumentError('username field is required'); + } + + if (typeof data.password !== 'string' || data.password.split().length === 0) { + throw new ArgumentError('password field is required'); + } + + if (typeof data.realm === 'string' && data.realm.split().length !== 0) { + data.grant_type = 'http://auth0.com/oauth/grant-type/password-realm'; + } + + const params = { + type: 'token', + ...getParamsFromOptions(sanitizedOptions), + }; + + if (sanitizedCb && sanitizedCb instanceof Function) { + return this.oauthWithIDTokenValidation.create(params, data, sanitizedCb); + } + + return this.oauthWithIDTokenValidation.create(params, data); } - if (cb && cb instanceof Function) { - return this.oauth.create(params, data, cb); + /** + * Exchange a refresh token + * + * @example + * Given a refresh token from a previous authentication request + * it will return a JSON with the access_token and id_token if + * the openid scope was originally included. + * More information in the + * + * API Docs + * . + * + * + * var data = { + * refresh_token: '{REFRESH_TOKEN}', + * }; + * + * auth0.oauth.refreshToken(data, function (err, data) { + * if (err) { + * // Handle error. + * } + * + * console.log(data); + * }); + * @param {object} data Data object. + * @param {string} data.refresh_token Refresh token. + * @param {Function} cb Callback + * @returns {Promise|undefined} + */ + refreshToken(data, cb) { + if (!data || typeof data !== 'object') { + throw new ArgumentError('Missing data object'); + } + + data = { + client_id: this.clientId, + client_secret: this.clientSecret, + grant_type: 'refresh_token', + ...data, + }; + + if (typeof data.refresh_token !== 'string' || data.refresh_token.split().length === 0) { + throw new ArgumentError('refresh_token is required'); + } + + const params = { + type: 'token', + }; + + if (cb && cb instanceof Function) { + return this.oauth.create(params, data, cb); + } + return this.oauth.create(params, data); } - return this.oauth.create(params, data); -}; - -OAuthAuthenticator.prototype.clientCredentialsGrant = function(options, cb) { - var params = { - type: 'token' - }; - - var defaultFields = { - grant_type: 'client_credentials', - client_id: this.clientId, - client_secret: this.clientSecret - }; + /** + * Sign in using a social provider access token. + * + * @param {object} data User credentials object. + * @param {string} data.access_token User access token. + * @param {string} data.connection Identity provider. + * @param {Function} cb Callback + * @returns {Promise|undefined} + */ + socialSignIn(data, cb) { + const params = { + type: 'access_token', + }; - var data = extend(defaultFields, options); + if (typeof data !== 'object') { + throw new ArgumentError('Missing user credential objects'); + } - if (!options || typeof options !== 'object') { - throw new ArgumentError('Missing options object'); - } + if (typeof data.access_token !== 'string' || data.access_token.trim().length === 0) { + throw new ArgumentError('access_token field is required'); + } - if (!data.client_id || data.client_id.trim().length === 0) { - throw new ArgumentError('client_id field is required'); - } + if (typeof data.connection !== 'string' || data.connection.trim().length === 0) { + throw new ArgumentError('connection field is required'); + } - if (!data.client_secret || data.client_secret.trim().length === 0) { - throw new ArgumentError('client_secret field is required'); - } + if (cb && cb instanceof Function) { + return this.oauth.create(params, data, cb); + } - if (cb && cb instanceof Function) { - return this.oauth.create(params, data, cb); + return this.oauth.create(params, data); } - return this.oauth.create(params, data); -}; + clientCredentialsGrant(options, cb) { + if (!options || typeof options !== 'object') { + throw new ArgumentError('Missing options object'); + } -/** - * Sign in using an authorization code - * - * @method authorizationCodeGrant - * @memberOf module:auth.OAuthAuthenticator.prototype - * - * @example - * Given the code returned in the URL params after the redirect - * from successful authentication, exchange the code for auth0 - * credentials. It will return JSON with the access_token and id_token. - * More information in the - * - * API Docs - * . - * - * - * var data = { - * code: '{CODE}', - * redirect_uri: '{REDIRECT_URI}', - * client_id: '{CLIENT_ID}', // Optional field. - * client_secret: '{CLIENT_SECRET}', // Optional field. - * }; - * - * auth0.oauth.authorizationCodeGrant(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} data Authorization code payload - * @param {String} userData.code Code in URL returned after authentication - * @param {String} userData.redirect_uri The URL to which Auth0 will redirect the browser after authorization has been granted by the user. - * - * @return {Promise|undefined} - */ -OAuthAuthenticator.prototype.authorizationCodeGrant = function(options, cb) { - var params = { - type: 'token' - }; + const data = { + grant_type: 'client_credentials', + client_id: this.clientId, + client_secret: this.clientSecret, + ...options, + }; - var defaultFields = { - grant_type: 'authorization_code', - client_id: this.clientId, - client_secret: this.clientSecret - }; + if (!data.client_id || data.client_id.trim().length === 0) { + throw new ArgumentError('client_id field is required'); + } - var data = extend(defaultFields, options); + if (!data.client_secret || data.client_secret.trim().length === 0) { + throw new ArgumentError('client_secret field is required'); + } - if (!options || typeof options !== 'object') { - throw new ArgumentError('Missing options object'); - } + const params = { + type: 'token', + }; - if (!data.code || data.code.trim().length === 0) { - throw new ArgumentError('code field is required'); - } + if (cb && cb instanceof Function) { + return this.oauth.create(params, data, cb); + } - if (!data.redirect_uri || data.redirect_uri.trim().length === 0) { - throw new ArgumentError('redirect_uri field is required'); + return this.oauth.create(params, data); } - if (cb && cb instanceof Function) { - return this.oauthWithIDTokenValidation.create(params, data, cb); + /** + * Sign in using an authorization code + * + * @example + * Given the code returned in the URL params after the redirect + * from successful authentication, exchange the code for auth0 + * credentials. It will return JSON with the access_token and id_token. + * More information in the + * + * API Docs + * . + * + * + * var options = { + * code: '{CODE}', + * redirect_uri: '{REDIRECT_URI}', + * organization: '{ORGANIZATION_ID}' // Optiional field. + * }; + * + * auth0.oauth.authorizationCodeGrant(options, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} options Authorization code payload + * @param {string} options.organization Organization ID + * @param {string} options.code Code in URL returned after authentication + * @param {string} options.redirect_uri The URL to which Auth0 will redirect the browser after authorization has been granted by the user. + * @param {Function} cb Callback + * @returns {Promise|undefined} + */ + authorizationCodeGrant(options, cb) { + if (!options || typeof options !== 'object') { + throw new ArgumentError('Missing options object'); + } + + const data = { + grant_type: 'authorization_code', + client_id: this.clientId, + client_secret: this.clientSecret, + ...options, + }; + + if (!data.code || data.code.trim().length === 0) { + throw new ArgumentError('code field is required'); + } + + if (!data.redirect_uri || data.redirect_uri.trim().length === 0) { + throw new ArgumentError('redirect_uri field is required'); + } + + const params = { + type: 'token', + }; + + if (cb && cb instanceof Function) { + return this.oauthWithIDTokenValidation.create(params, data, cb); + } + + return this.oauthWithIDTokenValidation.create(params, data); } - - return this.oauthWithIDTokenValidation.create(params, data); -}; +} module.exports = OAuthAuthenticator; diff --git a/src/auth/PasswordlessAuthenticator.js b/src/auth/PasswordlessAuthenticator.js index 99c124275..44c849f09 100644 --- a/src/auth/PasswordlessAuthenticator.js +++ b/src/auth/PasswordlessAuthenticator.js @@ -1,235 +1,286 @@ -var extend = require('util')._extend; +const { ArgumentError } = require('rest-facade'); +const RestClient = require('rest-facade').Client; +const { sanitizeArguments } = require('../utils'); -var ArgumentError = require('rest-facade').ArgumentError; -var RestClient = require('rest-facade').Client; +function getParamsFromOptions(options) { + const params = {}; + if (!options || typeof options !== 'object') { + return params; + } + if (options.forwardedFor) { + params._requestCustomizer = function (req) { + req.set('auth0-forwarded-for', options.forwardedFor); + }; + } + return params; +} /** - * @class * Handles authenticator with passwordless flows, e.g. SMS, Touch ID, etc. - * @constructor - * @memberOf module:auth - * - * @param {Object} options Authenticator options. - * @param {String} options.baseUrl The auth0 account URL. - * @param {String} [options.clientId] Default client ID. - * @param {OAuthAuthenticator} oauth OAuthAuthenticator instance. */ -var PasswordlessAuthenticator = function(options, oauth) { - if (!options) { - throw new ArgumentError('Missing authenticator options'); - } - if (typeof options !== 'object') { - throw new ArgumentError('The authenticator options must be an object'); +class PasswordlessAuthenticator { + /** + * @param {object} options Authenticator options. + * @param {string} options.baseUrl The auth0 account URL. + * @param {string} [options.clientId] Default client ID. + * @param {string} [options.clientSecret] Default client secret. + * @param {OAuthAuthenticator} oauth OAuthAuthenticator instance. + */ + constructor(options, oauth) { + if (!options) { + throw new ArgumentError('Missing authenticator options'); + } + + if (typeof options !== 'object') { + throw new ArgumentError('The authenticator options must be an object'); + } + + /** + * Options object for the Rest Client instance. + * + * @type {object} + */ + const clientOptions = { + errorFormatter: { message: 'message', name: 'error' }, + headers: options.headers, + }; + + this.oauth = oauth; + this.passwordless = new RestClient(`${options.baseUrl}/passwordless/start`, clientOptions); + this.clientId = options.clientId; + this.clientSecret = options.clientSecret; } /** - * Options object for the Rest Client instace. + * Sign in with the given user credentials. + * + * @example + * Once you have a verification code, use this endpoint to login + * the user with their phone number/email and verification code. + * + * https://auth0.com/docs/api/authentication#authenticate-user + * + * + * var data = { + * username: '{PHONE_NUMBER OR EMAIL}', + * otp: '{VERIFICATION_CODE}', + * realm: '{sms or email}' // OPTIONAL DEFAULTS TO SMS + * }; + * + * auth0.passwordless.signIn(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @example + * The user data object has the following structure. + * * - * @type {Object} + * { + * id_token: String, + * access_token: String, + * token_type: String + * } + * @example + * LEGACY signIn using the `/oauth/ro` endpoint. When otp is not specified + * password is required. Given the user credentials (`phone_number` and `code`), + * it will do the authentication on the provider and return a JSON with + * the `access_token` and `id_token`. + * + * https://auth0.com/docs/api/authentication#resource-owner + * + * + * var data = { + * username: '{PHONE_NUMBER}', + * password: '{VERIFICATION_CODE}' + * }; + * + * auth0.passwordless.signIn(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} userData User credentials object. + * @param {string} userData.username The user's phone number if realm=sms, or the user's email if realm=email + * @param {string} userData.otp The user's verification code. Required + * @param {string} [userData.audience] API Identifier of the API for which you want to get an Access Token. + * @param {string} [userData.realm=sms] Realm string: "sms" or "email". + * @param {string} [userData.password] [DEPRECATED] Password required if using legacy /oauth/ro endpoint + * @param {string} [userData.connection=sms] [DEPRECATED] Connection string: "sms" or "email". + * @param {object} [options] Additional options. + * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' } - }; + signIn(userData, options, cb) { + const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb); - this.oauth = oauth; - this.passwordless = new RestClient(options.baseUrl + '/passwordless/start', clientOptions); - this.clientId = options.clientId; -}; + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } -/** - * Sign in with the given user credentials. - * - * @method signIn - * @memberOf module:auth.PasswordlessAuthenticator.prototype - * @example - * Given the user credentials (`phone_number` and `code`), it will do the - * authentication on the provider and return a JSON with the `access_token` - * and `id_token`. - * - * - * var data = { - * username: '{PHONE_NUMBER}', - * password: '{VERIFICATION_CODE}' - * }; - * - * auth0.passwordless.signIn(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @example - * The user data object has the following structure. - * - * - * { - * id_token: String, - * access_token: String, - * token_type: String - * } - * - * @param {Object} userData User credentials object. - * @param {String} userData.username Username. - * @param {String} userData.password Password. - * @param {String} [userData.connection=sms] Connection string: "sms" or "email". - * @param {String} [userData.client_id] Client ID. - * @param {Function} [cb] Method callback. - * - * @return {Promise|undefined} - */ -PasswordlessAuthenticator.prototype.signIn = function(userData, cb) { - var defaultFields = { - client_id: this.clientId - }; - var data = extend(defaultFields, userData); - - // Don't let the user override the connection nor the grant type. - if (!data.connection || (data.connection !== 'email' && data.connection !== 'sms')) { - data.connection = 'sms'; - } - data.grant_type = 'password'; + const data = { + client_id: this.clientId, + client_secret: this.clientSecret, + ...userData, + }; - if (!userData || typeof userData !== 'object') { - throw new ArgumentError('Missing user data object'); - } + if (typeof data.username !== 'string' || data.username.trim().length === 0) { + throw new ArgumentError('username field (phone number) is required'); + } - if (typeof data.username !== 'string' || data.username.trim().length === 0) { - throw new ArgumentError('username field (phone number) is required'); - } + // If otp is provided, attempt to sign in using otp grant + if (typeof data.otp === 'string' && data.otp.trim().length > 0) { + if (!data.realm || (data.realm !== 'email' && data.realm !== 'sms')) { + data.realm = 'sms'; + } + data.grant_type = 'http://auth0.com/oauth/grant-type/passwordless/otp'; + return this.oauth.signIn(data, { type: 'token', ...sanitizedOptions }, sanitizedCb); + } + + // Don't let the user override the connection nor the grant type. + if (!data.connection || (data.connection !== 'email' && data.connection !== 'sms')) { + data.connection = 'sms'; + } + data.grant_type = 'password'; + + if (typeof data.password !== 'string' || data.password.trim().length === 0) { + throw new ArgumentError('password field (verification code) is required'); + } - if (typeof data.password !== 'string' || data.password.trim().length === 0) { - throw new ArgumentError('password field (verification code) is required'); + console.warn( + 'The oauth/ro endpoint has been deprecated. Please use the realm and otp parameters in this function.' + ); + return this.oauth.signIn(data, sanitizedOptions, sanitizedCb); } - return this.oauth.signIn(data, cb); -}; + /** + * Start passwordless flow sending an email. + * + * @example + * Given the user `email` address, it will send an email with: + * + *
    + *
  • A link (default, `send:"link"`). You can then authenticate with this + * user opening the link and he will be automatically logged in to the + * application. Optionally, you can append/override parameters to the link + * (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using + * `authParams` object. + *
  • + *
  • + * A verification code (`send:"code"`). You can then authenticate with + * this user using the `/oauth/ro` endpoint specifying `email` as + * `username` and `code` as `password`. + *
  • + *
+ * + * Find more information in the + * API Docs + * + * + * var data = { + * email: '{EMAIL}', + * send: 'link', + * authParams: {} // Optional auth params. + * }; + * + * auth0.passwordless.sendEmail(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} userData User account data. + * @param {string} userData.email User email address. + * @param {string} userData.send The type of email to be sent. + * @param {object} [options] Additional options. + * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + sendEmail(userData, options, cb) { + const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb); + const data = { + client_id: this.clientId, + client_secret: this.clientSecret, + ...userData, + }; + const params = getParamsFromOptions(sanitizedOptions); -/** - * Start passwordless flow sending an email. - * - * @method sendEmail - * @memberOf module:auth.PasswordlessAuthenticator.prototype - * @example - * Given the user `email` address, it will send an email with: - * - *
    - *
  • A link (default, `send:"link"`). You can then authenticate with this - * user opening the link and he will be automatically logged in to the - * application. Optionally, you can append/override parameters to the link - * (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using - * `authParams` object. - *
  • - *
  • - * A verification code (`send:"code"`). You can then authenticate with - * this user using the `/oauth/ro` endpoint specifying `email` as - * `username` and `code` as `password`. - *
  • - *
- * - * Find more information in the - * API Docs - * - * - * var data = { - * email: '{EMAIL}', - * send: 'link', - * authParams: {} // Optional auth params. - * }; - * - * auth0.passwordless.sendEmail(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} userData User account data. - * @param {String} userData.email User email address. - * @param {String} userData.send The type of email to be sent. - * @param {Function} [cb] Method callback. - * - * @return {Promise|undefined} - */ -PasswordlessAuthenticator.prototype.sendEmail = function(userData, cb) { - var defaultFields = { - client_id: this.clientId - }; - var data = extend(defaultFields, userData); + // Don't let the user override the connection nor the grant type. + data.connection = 'email'; - // Don't let the user override the connection nor the grant type. - data.connection = 'email'; + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } - if (!userData || typeof userData !== 'object') { - throw new ArgumentError('Missing user data object'); - } + if (typeof data.email !== 'string' || data.email.trim().length === 0) { + throw new ArgumentError('email field is required'); + } - if (typeof data.email !== 'string' || data.email.trim().length === 0) { - throw new ArgumentError('email field is required'); - } + if (typeof data.send !== 'string' || data.send.trim().length === 0) { + throw new ArgumentError('send field is required'); + } - if (typeof data.send !== 'string' || data.send.trim().length === 0) { - throw new ArgumentError('send field is required'); - } + if (sanitizedCb && sanitizedCb instanceof Function) { + return this.passwordless.create(params, data, sanitizedCb); + } - if (cb && cb instanceof Function) { - return this.passwordless.create(data, cb); + return this.passwordless.create(params, data); } - return this.passwordless.create(data); -}; + /** + * Start passwordless flow sending an SMS. + * + * @example + * Given the user `phone_number`, it will send a SMS message with a + * verification code. You can then authenticate with this user using the + * `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as + * `password`: + * + * + * var data = { + * phone_number: '{PHONE}' + * }; + * + * auth0.passwordless.sendSMS(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} userData User account data. + * @param {string} userData.phone_number User phone number. + * @param {object} [options] Additional options. + * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + sendSMS(userData, options, cb) { + const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb); + const data = { + client_id: this.clientId, + client_secret: this.clientSecret, + ...userData, + }; + const params = getParamsFromOptions(sanitizedOptions); -/** - * Start passwordless flow sending an SMS. - * - * @method sendSMS - * @memberOf module:auth.PasswordlessAuthenticator.prototype - * - * @example - * Given the user `phone_number`, it will send a SMS message with a - * verification code. You can then authenticate with this user using the - * `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as - * `password`: - * - * - * var data = { - * phone_number: '{PHONE}' - * }; - * - * auth0.passwordless.sendSMS(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} userData User account data. - * @param {String} userData.phone_number User phone number. - * @param {String} [userData.client_id] Client ID. - * @param {Function} [cb] Method callback. - * - * @return {Promise|undefined} - */ -PasswordlessAuthenticator.prototype.sendSMS = function(userData, cb) { - var defaultFields = { - client_id: this.clientId - }; - var data = extend(defaultFields, userData); + // Don't let the user override the connection nor the grant type. + data.connection = 'sms'; - // Don't let the user override the connection nor the grant type. - data.connection = 'sms'; + if (!userData || typeof userData !== 'object') { + throw new ArgumentError('Missing user data object'); + } - if (!userData || typeof userData !== 'object') { - throw new ArgumentError('Missing user data object'); - } + if (typeof data.phone_number !== 'string' || data.phone_number.trim().length === 0) { + throw new ArgumentError('phone_number field is required'); + } - if (typeof data.phone_number !== 'string' || data.phone_number.trim().length === 0) { - throw new ArgumentError('phone_number field is required'); - } + if (sanitizedCb && sanitizedCb instanceof Function) { + return this.passwordless.create(params, data, sanitizedCb); + } - if (cb && cb instanceof Function) { - return this.passwordless.create(data, cb); + return this.passwordless.create(params, data); } - - return this.passwordless.create(data); -}; +} module.exports = PasswordlessAuthenticator; diff --git a/src/auth/TokensManager.js b/src/auth/TokensManager.js index b8c5af22a..b7f4164ba 100644 --- a/src/auth/TokensManager.js +++ b/src/auth/TokensManager.js @@ -1,175 +1,242 @@ -var extend = require('util')._extend; -var getRequestPromise = require('../utils').getRequestPromise; - -var ArgumentError = require('rest-facade').ArgumentError; +const axios = require('axios'); +const { ArgumentError } = require('rest-facade'); /** - * @class * Provides methods for getting token data and exchanging tokens. - * @constructor - * @memberOf module:auth - * - * @param {Object} options Manager options. - * @param {String} options.baseUrl The auth0 account URL. - * @param {String} [options.headers] Default request headers. - * @param {String} [options.clientId] Default client ID. - */ -var TokensManager = function(options) { - if (typeof options !== 'object') { - throw new ArgumentError('Missing tokens manager options'); - } - - if (typeof options.baseUrl !== 'string') { - throw new ArgumentError('baseUrl field is required'); - } - - this.baseUrl = options.baseUrl; - this.headers = options.headers || {}; - this.clientId = options.clientId || ''; -}; - -/** - * Given an ID token get the user profile linked to it. - * - * @method - * @memberOf module:auth.TokensManager.prototype - * - * @example - * Validates a JSON Web Token (signature and expiration) and returns the user - * information associated with the user id (sub property) of the token. Find - * more information in the - * API Docs. - * - * - * auth0.tokens.getInfo(token, function (err, tokenInfo) { - * if (err) { - * // Handle error. - * } - * - * console.log(tokenInfo); - * }); - * - * @param {String} idToken User ID token. - * @param {Function} [cb] Method callback. - * - * @return {Promise|undefined} - */ -TokensManager.prototype.getInfo = function(idToken, cb) { - var headers = extend({}, this.headers); - - if (idToken === null || idToken === undefined) { - throw new ArgumentError('An ID token is required'); - } - - if (typeof idToken !== 'string' || idToken.trim().length === 0) { - throw new ArgumentError('The ID token is not valid'); - } - - // Perform the request. - var promise = getRequestPromise({ - method: 'POST', - url: this.baseUrl + '/tokeninfo', - data: { id_token: idToken }, - headers: headers - }); - - // Use callback if given. - if (cb instanceof Function) { - promise.then(cb.bind(null, null)).catch(cb); - return; - } - - return promise; -}; - -/** - * Exchange the token of the logged in user with a token that is valid to call - * the API (signed with the API secret). - * - * @method - * @memberOf module:auth.TokensManager.prototype - * - * @example - * Given an existing token, this endpoint will generate a new token signed - * with the target client secret. This is used to flow the identity of the - * user from the application to an API or across different APIs that are - * protected with different secrets. Find more information in the - * API Docs. - * - * - * var data = { - * id_token: '{ID_TOKEN}', - * api_type: 'app', - * target: '{TARGET}', - * grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer' - * }; - * - * auth0.tokens.getDelegationToken(data, function (err, token) { - * if (err) { - * // Handle error. - * } - * - * console.log(token); - * }); - * - * @param {Object} data Token data object. - * @param {String} data.id_token User ID token. - * @param {String} data.refresh_token User refresh token. - * @param {String} data.target Target client ID. - * @param {String} data.api_type The API to be used (aws, auth0, etc). - * @param {String} data.grant_type Grant type (password, jwt, etc). - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} */ -TokensManager.prototype.getDelegationToken = function(data, cb) { - var body = extend({ client_id: this.clientId }, data); - var headers = this.headers; - - if (!data) { - throw new ArgumentError('Missing token data object'); - } - - var hasIdToken = typeof data.id_token === 'string' && data.id_token.trim().length !== 0; - - var hasRefreshToken = - typeof data.refresh_token === 'string' && data.refresh_token.trim().length !== 0; - - if (!hasIdToken && !hasRefreshToken) { - throw new ArgumentError('one of id_token or refresh_token is required'); - } - - if (hasIdToken && hasRefreshToken) { - throw new ArgumentError('id_token and refresh_token fields cannot be specified simulatenously'); +class TokensManager { + /** + * @param {object} options Manager options. + * @param {string} options.baseUrl The auth0 account URL. + * @param {string} [options.headers] Default request headers. + * @param {string} [options.clientId] Default client ID. + * @param {string} [options.clientSecret] Default client Secret. + */ + constructor(options) { + if (typeof options !== 'object') { + throw new ArgumentError('Missing tokens manager options'); + } + + if (typeof options.baseUrl !== 'string') { + throw new ArgumentError('baseUrl field is required'); + } + + this.baseUrl = options.baseUrl; + this.headers = options.headers || {}; + this.clientId = options.clientId || ''; + this.clientSecret = options.clientSecret || ''; } - if (typeof data.target !== 'string' || data.target.trim().length === 0) { - throw new ArgumentError('target field is required'); + /** + * Given an ID token get the user profile linked to it. + * + * @example + * Validates a JSON Web Token (signature and expiration) and returns the user + * information associated with the user id (sub property) of the token. Find + * more information in the + * API Docs. + * + * + * auth0.tokens.getInfo(token, function (err, tokenInfo) { + * if (err) { + * // Handle error. + * } + * + * console.log(tokenInfo); + * }); + * @param {string} idToken User ID token. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + getInfo(idToken, cb) { + const headers = { ...this.headers }; + + if (idToken === null || idToken === undefined) { + throw new ArgumentError('An ID token is required'); + } + + if (typeof idToken !== 'string' || idToken.trim().length === 0) { + throw new ArgumentError('The ID token is not valid'); + } + + // Perform the request. + const promise = axios({ + method: 'POST', + url: `${this.baseUrl}/tokeninfo`, + data: { id_token: idToken }, + headers, + }).then(({ data }) => data); + + // Use callback if given. + if (cb instanceof Function) { + promise.then(cb.bind(null, null)).catch(cb); + return; + } + + return promise; } - if (typeof data.api_type !== 'string' || data.api_type.trim().length === 0) { - throw new ArgumentError('api_type field is required'); + /** + * Exchange the token of the logged in user with a token that is valid to call + * the API (signed with the API secret). + * + * @example + * Given an existing token, this endpoint will generate a new token signed + * with the target client secret. This is used to flow the identity of the + * user from the application to an API or across different APIs that are + * protected with different secrets. Find more information in the + * API Docs. + * + * + * var data = { + * id_token: '{ID_TOKEN}', + * api_type: 'app', + * target: '{TARGET}', + * grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer' + * }; + * + * auth0.tokens.getDelegationToken(data, function (err, token) { + * if (err) { + * // Handle error. + * } + * + * console.log(token); + * }); + * @param {object} data Token data object. + * @param {string} data.id_token User ID token. + * @param {string} data.refresh_token User refresh token. + * @param {string} data.target Target client ID. + * @param {string} data.api_type The API to be used (aws, auth0, etc). + * @param {string} data.grant_type Grant type (password, jwt, etc). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getDelegationToken(data, cb) { + const body = { client_id: this.clientId, ...data }; + const { headers } = this; + + if (!data) { + throw new ArgumentError('Missing token data object'); + } + + const hasIdToken = typeof data.id_token === 'string' && data.id_token.trim().length !== 0; + + const hasRefreshToken = + typeof data.refresh_token === 'string' && data.refresh_token.trim().length !== 0; + + if (!hasIdToken && !hasRefreshToken) { + throw new ArgumentError('one of id_token or refresh_token is required'); + } + + if (hasIdToken && hasRefreshToken) { + throw new ArgumentError( + 'id_token and refresh_token fields cannot be specified simulatenously' + ); + } + + if (typeof data.target !== 'string' || data.target.trim().length === 0) { + throw new ArgumentError('target field is required'); + } + + if (typeof data.api_type !== 'string' || data.api_type.trim().length === 0) { + throw new ArgumentError('api_type field is required'); + } + + if (typeof data.grant_type !== 'string' || data.grant_type.trim().length === 0) { + throw new ArgumentError('grant_type field is required'); + } + + // Perform the request. + const promise = axios({ + method: 'POST', + url: `${this.baseUrl}/delegation`, + data: body, + headers, + }).then(({ data }) => data); + + // Use callback if given. + if (cb instanceof Function) { + promise.then(cb.bind(null, null)).catch(cb); + return; + } + + return promise; } - if (typeof data.grant_type !== 'string' || data.grant_type.trim().length === 0) { - throw new ArgumentError('grant_type field is required'); + /** + * Proactively revoke an issued refresh token. + * + * @example + * Given an existing refresh token, this endpoint will revoke it in order + * to prevent unauthorized silently user authentication tokens refresh. + * Find more information in the API Docs. + * + * + * var data = { + * token: '{REFRESH_TOKEN}' + * }; + * + * auth0.tokens.revokeRefreshToken(data, function (err, _) { + * if (err) { + * // Handle error. + * } + * + * // Do stuff. + * }); + * @param {object} data Token data object. + * @param {string} data.token User refresh token. + * @param {string} [data.client_id] Target client ID. + * @param {string} [data.client_secret] Target client secret. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + revokeRefreshToken(data, cb) { + if (!data) { + throw new ArgumentError('Missing token data object'); + } + + const hasToken = typeof data.token === 'string' && data.token.trim().length !== 0; + + if (!hasToken) { + throw new ArgumentError('token property is required'); + } + + const hasClientId = + (data.client_id && + typeof data.client_id === 'string' && + data.client_id.trim().length !== 0) || + this.clientId !== ''; + + if (!hasClientId) { + throw new ArgumentError( + 'Neither token data client_id property or constructor clientId property has been set' + ); + } + + const body = { + client_id: this.clientId, + client_secret: this.clientSecret, + ...data, + }; + + const { headers } = this; + + // Perform the request. + const promise = axios({ + method: 'POST', + url: `${this.baseUrl}/oauth/revoke`, + data: body, + headers, + }).then(({ data }) => data); + + // Use callback if given. + if (cb instanceof Function) { + promise.then(cb.bind(null, null)).catch(cb); + return; + } + + return promise; } - - // Perform the request. - var promise = getRequestPromise({ - method: 'POST', - url: this.baseUrl + '/delegation', - data: body, - headers: headers - }); - - // Use callback if given. - if (cb instanceof Function) { - promise.then(cb.bind(null, null)).catch(cb); - return; - } - - return promise; -}; +} module.exports = TokensManager; diff --git a/src/auth/UsersManager.js b/src/auth/UsersManager.js index 94e4606da..2d2393b4d 100644 --- a/src/auth/UsersManager.js +++ b/src/auth/UsersManager.js @@ -1,173 +1,161 @@ -var extend = require('util')._extend; -var getRequestPromise = require('../utils').getRequestPromise; +const axios = require('axios'); -var ArgumentError = require('rest-facade').ArgumentError; +const { ArgumentError } = require('rest-facade'); /** - * @class * Provides methods for getting user information and impersonating users. - * @constructor - * @memberOf module:auth - * - * @param {Object} options Manager options. - * @param {String} options.baseUrl The auth0 account URL. - * @param {String} [options.headers] Default request headers. - * @param {String} [options.clientId] Default client ID. */ -var UsersManager = function(options) { - if (typeof options !== 'object') { - throw new ArgumentError('Missing users manager options'); +class UsersManager { + /** + * @param {object} options Manager options. + * @param {string} options.baseUrl The auth0 account URL. + * @param {string} [options.headers] Default request headers. + * @param {string} [options.clientId] Default client ID. + */ + constructor(options) { + if (typeof options !== 'object') { + throw new ArgumentError('Missing users manager options'); + } + + if (typeof options.baseUrl !== 'string') { + throw new ArgumentError('baseUrl field is required'); + } + + this.baseUrl = options.baseUrl; + this.headers = options.headers; + this.clientId = options.clientId; } - if (typeof options.baseUrl !== 'string') { - throw new ArgumentError('baseUrl field is required'); + /** + * Given an access token get the user profile linked to it. + * + * @example + * Get the user information based on the Auth0 access token (obtained during + * login). Find more information in the + * API Docs. + * + * + * auth0.users.getInfo(accessToken, function (err, userInfo) { + * if (err) { + * // Handle error. + * } + * + * console.log(userInfo); + * }); + * @param {string} accessToken User access token. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getInfo(accessToken, cb) { + const url = `${this.baseUrl}/userinfo`; + const headers = { ...this.headers }; + + if (accessToken === null || accessToken === undefined) { + throw new ArgumentError('An access token is required'); + } + + if (typeof accessToken !== 'string' || accessToken.trim().length === 0) { + throw new ArgumentError('Invalid access token'); + } + + // Send the user access token in the Authorization header. + headers['Authorization'] = `Bearer ${accessToken}`; + + // Perform the request. + const promise = axios({ + method: 'GET', + url, + headers, + }).then(({ data }) => data); + + // Use callback if given. + if (cb instanceof Function) { + promise.then(cb.bind(null, null)).catch(cb); + return; + } + + return promise; } - this.baseUrl = options.baseUrl; - this.headers = options.headers; - this.clientId = options.clientId; -}; - -/** - * Given an access token get the user profile linked to it. - * - * @method getInfo - * @memberOf module:auth.UsersManager.prototype - * - * @example - * Get the user information based on the Auth0 access token (obtained during - * login). Find more information in the - * API Docs. - * - * - * auth0.users.getInfo(accessToken, function (err, userInfo) { - * if (err) { - * // Handle error. - * } - * - * console.log(userInfo); - * }); - * - * @param {String} accessToken User access token. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.getInfo = function(accessToken, cb) { - var url = this.baseUrl + '/userinfo'; - var headers = extend({}, this.headers); - - if (accessToken === null || accessToken === undefined) { - throw new ArgumentError('An access token is required'); - } - - if (typeof accessToken !== 'string' || accessToken.trim().length === 0) { - throw new ArgumentError('Invalid access token'); - } - - // Send the user access token in the Authorization header. - headers['Authorization'] = 'Bearer ' + accessToken; - - // Perform the request. - var promise = getRequestPromise({ - method: 'GET', - url: url, - headers: headers, - data: {} - }); - - // Use callback if given. - if (cb instanceof Function) { - promise.then(cb.bind(null, null)).catch(cb); - return; - } - - return promise; -}; - -/** - * Impersonate the user with the given user ID. - * - * @method impersonate - * @memberOf module:auth.UsersManager.prototype - * - * @example - * Gets a link that can be used once to log in as a specific user. Useful for - * troubleshooting. Find more information in the - * [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate). - * - * - * var settings = { - * impersonator_id: '{IMPERSONATOR_ID}', - * protocol: 'oauth2', - * additionalParameters: {} // Optional aditional params. - * }; - * - * auth0.users.impersonate(userId, settings, function (err, link) { - * if (err) { - * // Handle error. - * } - * - * console.log(link); - * }); - * - * @param {String} userId User ID token. - * @param {Object} settings Impersonation settings. - * @param {String} settings.impersonator_id Impersonator user ID. - * @param {String} settings.protocol The authentication protocol. - * @param {String} settings.token API v1 token obtained for impersonation - * @param {String} [settings.clientId] Client id used for impersonation. Uses the one supplied in the constructor by default. - * @param {Function} [cb]] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.impersonate = function(userId, settings, cb) { - var url = this.baseUrl + '/users/' + userId + '/impersonate'; - - if (userId === null || userId === undefined) { - throw new ArgumentError('You must specify a user ID'); + /** + * Impersonate the user with the given user ID. + * + * @example + * Gets a link that can be used once to log in as a specific user. Useful for + * troubleshooting. Find more information in the + * [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate). + * + * + * var settings = { + * impersonator_id: '{IMPERSONATOR_ID}', + * protocol: 'oauth2', + * additionalParameters: {} // Optional additional params. + * }; + * + * auth0.users.impersonate(userId, settings, function (err, link) { + * if (err) { + * // Handle error. + * } + * + * console.log(link); + * }); + * @param {string} userId User ID token. + * @param {object} settings Impersonation settings. + * @param {string} settings.impersonator_id Impersonator user ID. + * @param {string} settings.protocol The authentication protocol. + * @param {string} settings.token API v1 token obtained for impersonation + * @param {string} [settings.clientId] Client id used for impersonation. Uses the one supplied in the constructor by default. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + impersonate(userId, settings, cb) { + const url = `${this.baseUrl}/users/${userId}/impersonate`; + + if (userId === null || userId === undefined) { + throw new ArgumentError('You must specify a user ID'); + } + + if (typeof userId !== 'string' || userId.trim().length === 0) { + throw new ArgumentError('The user ID is not valid'); + } + + if (typeof settings !== 'object') { + throw new ArgumentError('Missing impersonation settings object'); + } + + if ( + typeof settings.impersonator_id !== 'string' || + settings.impersonator_id.trim().length === 0 + ) { + throw new ArgumentError('impersonator_id field is required'); + } + + if (typeof settings.protocol !== 'string' || settings.protocol.trim().length === 0) { + throw new ArgumentError('protocol field is required'); + } + + if (typeof settings.token !== 'string' || settings.token.trim().length === 0) { + throw new ArgumentError('token field is required'); + } + + const data = { client_id: settings.clientId || this.clientId, ...settings }; + const headers = { Authorization: `Bearer ${settings.token}`, ...this.headers }; + // Perform the request. + const promise = axios({ + method: 'POST', + headers, + data, + url, + }).then(({ data }) => data); + + // Use callback if given. + if (cb instanceof Function) { + promise.then(cb.bind(null, null)).catch(cb); + return; + } + + return promise; } - - if (typeof userId !== 'string' || userId.trim().length === 0) { - throw new ArgumentError('The user ID is not valid'); - } - - if (typeof settings !== 'object') { - throw new ArgumentError('Missing impersonation settings object'); - } - - if ( - typeof settings.impersonator_id !== 'string' || - settings.impersonator_id.trim().length === 0 - ) { - throw new ArgumentError('impersonator_id field is required'); - } - - if (typeof settings.protocol !== 'string' || settings.protocol.trim().length === 0) { - throw new ArgumentError('protocol field is required'); - } - - if (typeof settings.token !== 'string' || settings.token.trim().length === 0) { - throw new ArgumentError('token field is required'); - } - - var data = extend({ client_id: settings.clientId || this.clientId }, settings); - var headers = extend({ Authorization: `Bearer ${settings.token}` }, this.headers); - // Perform the request. - var promise = getRequestPromise({ - method: 'POST', - headers: headers, - data: data, - url: url - }); - - // Use callback if given. - if (cb instanceof Function) { - promise.then(cb.bind(null, null)).catch(cb); - return; - } - - return promise; -}; +} module.exports = UsersManager; diff --git a/src/auth/idToken.js b/src/auth/idToken.js new file mode 100644 index 000000000..67743b07d --- /dev/null +++ b/src/auth/idToken.js @@ -0,0 +1,167 @@ +const urlDecodeB64 = function (data) { + return Buffer.from(data, 'base64').toString('utf8'); +}; + +/** + * Decodes a string token into the 3 parts, throws if the format is invalid + * + * @param {string} token token + * @returns {object} + */ +const decode = function (token) { + const parts = token.split('.'); + + if (parts.length !== 3) { + throw new Error('ID token could not be decoded'); + } + + return { + _raw: token, + header: JSON.parse(urlDecodeB64(parts[0])), + payload: JSON.parse(urlDecodeB64(parts[1])), + signature: parts[2], + }; +}; + +const DEFAULT_LEEWAY = 60; //default clock-skew, in seconds + +/** + * Validator for ID Tokens following OIDC spec. + * + * @param {string} token the string token to verify + * @param {object} options the options required to run this verification + * @returns {object} The decoded token payload, or throws an exception if validation failed + */ +const validate = function (token, options) { + if (!token) { + throw new Error('ID token is required but missing'); + } + + const decodedToken = decode(token); + + // Check algorithm + const { header } = decodedToken; + if (header.alg !== 'RS256' && header.alg !== 'HS256') { + throw new Error( + `Signature algorithm of "${header.alg}" is not supported. Expected the ID token to be signed with "RS256" or "HS256".` + ); + } + + const { payload } = decodedToken; + + // Issuer + if (!payload.iss || typeof payload.iss !== 'string') { + throw new Error('Issuer (iss) claim must be a string present in the ID token'); + } + if (payload.iss !== options.issuer) { + throw new Error( + `Issuer (iss) claim mismatch in the ID token; expected "${options.issuer}", found "${payload.iss}"` + ); + } + + // Subject + if (!payload.sub || typeof payload.sub !== 'string') { + throw new Error('Subject (sub) claim must be a string present in the ID token'); + } + + // Audience + if (!payload.aud || !(typeof payload.aud === 'string' || Array.isArray(payload.aud))) { + throw new Error( + 'Audience (aud) claim must be a string or array of strings present in the ID token' + ); + } + if (Array.isArray(payload.aud) && !payload.aud.includes(options.audience)) { + throw new Error( + `Audience (aud) claim mismatch in the ID token; expected "${ + options.audience + }" but was not one of "${payload.aud.join(', ')}"` + ); + } else if (typeof payload.aud === 'string' && payload.aud !== options.audience) { + throw new Error( + `Audience (aud) claim mismatch in the ID token; expected "${options.audience}" but found "${payload.aud}"` + ); + } + + // Organization + if (options.organization) { + if (!payload.org_id || typeof payload.org_id !== 'string') { + throw new Error('Organization Id (org_id) claim must be a string present in the ID token'); + } + + if (payload.org_id !== options.organization) { + throw new Error( + `Organization Id (org_id) claim value mismatch in the ID token; expected "${options.organization}", found "${payload.org_id}"'` + ); + } + } + + // --Time validation (epoch)-- + const now = Math.floor(Date.now() / 1000); + const leeway = options.leeway || DEFAULT_LEEWAY; + + // Expires at + if (!payload.exp || typeof payload.exp !== 'number') { + throw new Error('Expiration Time (exp) claim must be a number present in the ID token'); + } + const expTime = payload.exp + leeway; + + if (now > expTime) { + throw new Error( + `Expiration Time (exp) claim error in the ID token; current time (${now}) is after expiration time (${expTime})` + ); + } + + // Issued at + if (!payload.iat || typeof payload.iat !== 'number') { + throw new Error('Issued At (iat) claim must be a number present in the ID token'); + } + + // Nonce + if (options.nonce) { + if (!payload.nonce || typeof payload.nonce !== 'string') { + throw new Error('Nonce (nonce) claim must be a string present in the ID token'); + } + if (payload.nonce !== options.nonce) { + throw new Error( + `Nonce (nonce) claim mismatch in the ID token; expected "${options.nonce}", found "${payload.nonce}"` + ); + } + } + + // Authorized party + if (Array.isArray(payload.aud) && payload.aud.length > 1) { + if (!payload.azp || typeof payload.azp !== 'string') { + throw new Error( + 'Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values' + ); + } + if (payload.azp !== options.audience) { + throw new Error( + `Authorized Party (azp) claim mismatch in the ID token; expected "${options.audience}", found "${payload.azp}"` + ); + } + } + + // Authentication time + if (options.maxAge) { + if (!payload.auth_time || typeof payload.auth_time !== 'number') { + throw new Error( + 'Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified' + ); + } + + const authValidUntil = payload.auth_time + options.maxAge + leeway; + if (now > authValidUntil) { + throw new Error( + `Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Currrent time (${now}) is after last auth at ${authValidUntil}` + ); + } + } + + return decodedToken; +}; + +module.exports = { + decode, + validate, +}; diff --git a/src/auth/index.js b/src/auth/index.js index acb70f253..8a174ce56 100644 --- a/src/auth/index.js +++ b/src/auth/index.js @@ -1,31 +1,23 @@ -/** @module auth **/ - -var util = require('util'); - -var pkg = require('../../package.json'); -var utils = require('../utils'); -var jsonToBase64 = utils.jsonToBase64; -var ArgumentError = require('rest-facade').ArgumentError; +const util = require('util'); +const utils = require('../utils'); +const { jsonToBase64 } = utils; +const { ArgumentError } = require('rest-facade'); // Authenticators. -var OAuthAuthenticator = require('./OAuthAuthenticator'); -var DatabaseAuthenticator = require('./DatabaseAuthenticator'); -var PasswordlessAuthenticator = require('./PasswordlessAuthenticator'); +const OAuthAuthenticator = require('./OAuthAuthenticator'); +const DatabaseAuthenticator = require('./DatabaseAuthenticator'); +const PasswordlessAuthenticator = require('./PasswordlessAuthenticator'); // Managers -var UsersManager = require('./UsersManager'); -var TokensManager = require('./TokensManager'); +const UsersManager = require('./UsersManager'); +const TokensManager = require('./TokensManager'); -var BASE_URL_FORMAT = 'https://%s'; +const BASE_URL_FORMAT = 'https://%s'; /** - * @class * Authentication API SDK. * - * This client must used to access Auth0's - * Authentication API. - * @constructor - * @memberOf module:auth + * This client must used to access Auth0's {@link https://auth0.com/docs/auth-api Authentication API}. * * @example * The AuthenticationClient constructor takes an optional client @@ -38,544 +30,538 @@ var BASE_URL_FORMAT = 'https://%s'; * domain: '{YOUR_ACCOUNT}.auth0.com', * clientId: '{OPTIONAL_CLIENT_ID}' * }); - * - * @param {Object} options Options for the Authentication Client SDK. - * @param {String} options.domain AuthenticationClient server domain. - * @param {String} [options.clientId] Default client ID. - * @param {String} [options.clientSecret] Default client Secret. - * @param {String} [options.supportedAlgorithms] Algorithms that your application expects to receive */ -var AuthenticationClient = function(options) { - if (!options || typeof options !== 'object') { - throw new ArgumentError('Authentication Client SDK options must be an object'); +class AuthenticationClient { + /** + * @param {object} options Options for the Authentication Client SDK. + * @param {string} options.domain AuthenticationClient server domain. + * @param {string} [options.clientId] Default client ID. + * @param {string} [options.clientSecret] Default client Secret. + * @param {string} [options.supportedAlgorithms] Algorithms that your application expects to receive + * @param {boolean} [options.__bypassIdTokenValidation] Whether the id_token should be validated or not + * @param {object} [options.headers] Additional headers that will be added to the outgoing requests. + */ + constructor(options) { + if (!options || typeof options !== 'object') { + throw new ArgumentError('Authentication Client SDK options must be an object'); + } + + if (!options.domain || options.domain.length === 0) { + throw new ArgumentError('Must provide a domain'); + } + + const defaultHeaders = { + 'User-Agent': `node.js/${process.version.replace('v', '')}`, + 'Content-Type': 'application/json', + }; + + const managerOptions = { + clientId: options.clientId, + domain: options.domain, + clientSecret: options.clientSecret, + headers: Object.assign(defaultHeaders, options.headers || {}), + baseUrl: util.format(BASE_URL_FORMAT, options.domain), + supportedAlgorithms: options.supportedAlgorithms, + __bypassIdTokenValidation: options.__bypassIdTokenValidation, + }; + + if (options.telemetry !== false) { + const clientInfo = options.clientInfo || utils.generateClientInfo(); + if ('string' === typeof clientInfo.name && clientInfo.name) { + const telemetry = jsonToBase64(clientInfo); + managerOptions.headers['Auth0-Client'] = telemetry; + } + } + + /** + * OAuth authenticator. + * + * @type {OAuthAuthenticator} + */ + this.oauth = new OAuthAuthenticator(managerOptions); + + /** + * Database authenticator. + * + * @type {DatabaseAuthenticator} + */ + this.database = new DatabaseAuthenticator(managerOptions, this.oauth); + + /** + * Passwordless authenticator. + * + * @type {PasswordlessAuthenticator} + */ + this.passwordless = new PasswordlessAuthenticator(managerOptions, this.oauth); + + /** + * Users manager. + * + * @type {UsersManager} + */ + this.users = new UsersManager(managerOptions); + + /** + * Tokens manager. + * + * @type {TokensManager} + */ + this.tokens = new TokensManager(managerOptions); } - if (!options.domain || options.domain.length === 0) { - throw new ArgumentError('Must provide a domain'); - } + /** + * Start passwordless flow sending an email. + * + * @example + * Given the user `email` address, it will send an email with a link. You can + * then authenticate with this user opening the link and he will be + * automatically logged in to the application. Optionally, you can + * append/override parameters to the link (like `scope`, `redirect_uri`, + * `protocol`, `response_type`, etc.) using `authParams` object. + * + * Find more information in the + * API Docs + * + * + * var data = { + * email: '{EMAIL}', + * authParams: {} // Optional auth params. + * }; + * + * auth0.requestMagicLink(data, function (err) { + * if (err) { + * // Handle error. + * } + * }; + * @param {object} data User data object. + * @param {string} data.email User email address. + * @param {object} [data.authParams] Authentication parameters. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + requestMagicLink(data, cb) { + data.send = 'link'; - var managerOptions = { - clientId: options.clientId, - domain: options.domain, - clientSecret: options.clientSecret, - headers: { - 'User-agent': 'node.js/' + process.version.replace('v', ''), - 'Content-Type': 'application/json' - }, - baseUrl: util.format(BASE_URL_FORMAT, options.domain), - supportedAlgorithms: options.supportedAlgorithms - }; - - if (options.telemetry !== false) { - var telemetry = jsonToBase64(options.clientInfo || this.getClientInfo()); - managerOptions.headers['Auth0-Client'] = telemetry; + return this.passwordless.sendEmail(data, cb); } /** - * OAuth authenticator. + * Start passwordless flow sending an email. + * + * @example + * Given the user `email` address, it will send an email with a verification + * code. You can then authenticate with this user using the `/oauth/ro` + * endpoint using the email as username and the code as password. + * + * Find more information in the + * API Docs + * * - * @type {OAuthAuthenticator} + * var data = { + * email: '{EMAIL}', + * authParams: {} // Optional auth params. + * }; + * + * auth0.requestEmailCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * }; + * @param {object} data User data object. + * @param {string} data.email User email address. + * @param {object} [data.authParams] Authentication parameters. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.oauth = new OAuthAuthenticator(managerOptions); + requestEmailCode(data, cb) { + data.send = 'code'; + + return this.passwordless.sendEmail(data, cb); + } /** - * Database authenticator. + * Verify the given OTP which was sent on the given email. + * + * @example + * Given the user credentials (`email` and `otp`), authenticates + * with the provider using the `/oauth/token` endpoint. Upon successful + * authentication, returns a JSON object containing the `access_token` and + * `id_token`. + * * - * @type {DatabaseAuthenticator} + * var data = { + * email: '{EMAIL}', + * otp: '{VERIFICATION_CODE}' + * }; + * + * auth0.verifyEmailCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @example + * The user data object has the following structure. + * + * + * { + * id_token: String, + * access_token: String, + * token_type: String + * } + * @param {object} data Credentials object. + * @param {string} data.email Email. + * @param {string} data.otp Verification code. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.database = new DatabaseAuthenticator(managerOptions, this.oauth); + verifyEmailCode(data, cb) { + const translatedData = { + username: data.email, + realm: 'email', + otp: data.otp, + }; + + return this.passwordless.signIn(translatedData, cb); + } /** - * Passwordless authenticator. + * Start passwordless flow sending an SMS. * - * @type {PasswordlessAuthenticator} + * @example + * Given the user `phone_number`, it will send a SMS message with a + * verification code. You can then authenticate with this user using the + * `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as + * `password`: + * + * + * var data = { + * phone_number: '{PHONE}' + * }; + * + * auth0.requestSMSCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * }); + * @param {object} data User data object. + * @param {string} data.phone_number The user phone number. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.passwordless = new PasswordlessAuthenticator(managerOptions, this.oauth); + requestSMSCode(data, cb) { + const translatedData = { + phone_number: data.phoneNumber || data.phone_number, + }; + + return this.passwordless.sendSMS(translatedData, cb); + } /** - * Users manager. + * Sign in with the given user credentials. + * + * @example + * Given the user credentials (`phone_number` and `otp`), authenticates + * with the provider using the `/oauth/token` endpoint. Upon successful + * authentication, returns a JSON object containing the `access_token` and + * `id_token`. + * + * + * var data = { + * username: '{PHONE_NUMBER}' + * otp: '{VERIFICATION_CODE}' + * }; * - * @type {UsersManager} + * auth0.verifySMSCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @example + * Given the user credentials (`phone_number` and `password`), authenticates + * with the provider using the deprecated `/oauth/ro` endpoint. Upon successful + * authentication, returns a JSON object containing the `access_token` and + * `id_token`. + * + * + * var data = { + * username: '{PHONE_NUMBER}', + * password: '{VERIFICATION_CODE}' + * }; + * + * auth0.verifySMSCode(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @example + * The user data object has the following structure. + * + * + * { + * id_token: String, + * access_token: String, + * token_type: String + * } + * @param {object} data Credentials object. + * @param {string} data.username Phone number. + * @param {string} data.otp Verification code. Use this instead of `password` to use the `/oauth/token` endpoint. + * @param {string} data.password Verification code. Use this instead of `otp` to use the `/oauth/ro` endpoint. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.users = new UsersManager(managerOptions); + verifySMSCode(data, cb) { + const translatedData = { + username: data.phoneNumber || data.phone_number || data.username, + }; + + if (data.otp) { + translatedData.otp = data.otp; + } else { + translatedData.password = data.code || data.password; + } + + return this.passwordless.signIn(translatedData, cb); + } /** - * Tokens manager. + * Exchange the token of the logged in user with a token that is valid to call + * the API (signed with the API secret). + * + * @example + * Given an existing token, this endpoint will generate a new token signed + * with the target client secret. This is used to flow the identity of the + * user from the application to an API or across different APIs that are + * protected with different secrets. Find more information in the + * API Docs. + * + * + * var data = { + * id_token: '{ID_TOKEN}', + * api_type: 'app', + * target: '{TARGET}', + * grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer' + * }; + * + * auth0.getDelegationToken(data, function (err, token) { + * if (err) { + * // Handle error. + * } * - * @type {TokensManager} + * console.log(token); + * }); + * @param {object} data Token data object. + * @param {string} data.id_token The user ID token. + * @param {string} data.api_type The API type (aws, firebase, etc). + * @param {string} data.target The target client ID. + * @param {string} data.grant_type The grant type. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} */ - this.tokens = new TokensManager(managerOptions); -}; - -/** - * Return an object with information about the current client, - * - * @method getClientInfo - * @memberOf module:auth.AuthenticationClient.prototype - * - * @return {Object} Object containing client information. - */ -AuthenticationClient.prototype.getClientInfo = function() { - var clientInfo = { - name: 'node-auth0', - version: pkg.version, - dependencies: [], - environment: [ - { - name: 'node.js', - version: process.version.replace('v', '') - } - ] - }; - - // Add the dependencies to the client info object. - Object.keys(pkg.dependencies).forEach(function(name) { - clientInfo.dependencies.push({ - name: name, - version: pkg.dependencies[name] - }); - }); - - return clientInfo; -}; - -/** - * Start passwordless flow sending an email. - * - * @method requestMagicLink - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given the user `email` address, it will send an email with a link. You can - * then authenticate with this user opening the link and he will be - * automatically logged in to the application. Optionally, you can - * append/override parameters to the link (like `scope`, `redirect_uri`, - * `protocol`, `response_type`, etc.) using `authParams` object. - * - * Find more information in the - * API Docs - * - * - * var data = { - * email: '{EMAIL}', - * authParams: {} // Optional auth params. - * }; - * - * auth0.requestMagicLink(data, function (err) { - * if (err) { - * // Handle error. - * } - * }; - * - * @param {Object} data User data object. - * @param {String} data.email User email address. - * @param {Object} [data.authParams] Authentication parameters. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.requestMagicLink = function(data, cb) { - data.send = 'link'; - - return this.passwordless.sendEmail(data, cb); -}; - -/** - * Start passwordless flow sending an email. - * - * @method requestEmailCode - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given the user `email` address, it will send an email with a verification - * code. You can then authenticate with this user using the `/oauth/ro` - * endpoint using the email as username and the code as password. - * - * Find more information in the - * API Docs - * - * - * var data = { - * email: '{EMAIL}', - * authParams: {} // Optional auth params. - * }; - * - * auth0.requestEmailCode(data, function (err) { - * if (err) { - * // Handle error. - * } - * }; - * - * @param {Object} data User data object. - * @param {String} data.email User email address. - * @param {Object} [data.authParams] Authentication parameters. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.requestEmailCode = function(data, cb) { - data.send = 'code'; - - return this.passwordless.sendEmail(data, cb); -}; - -/** - * Start passwordless flow sending an SMS. - * - * @method requestSMSCode - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given the user `phone_number`, it will send a SMS message with a - * verification code. You can then authenticate with this user using the - * `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as - * `password`: - * - * - * var data = { - * phone_number: '{PHONE}' - * }; - * - * auth0.requestSMSCode(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * }); - * - * @param {Object} data User data object. - * @param {String} data.phone_number The user phone number. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.requestSMSCode = function(data, cb) { - var translatedData = { - phone_number: data.phoneNumber || data.phone_number - }; - - return this.passwordless.sendSMS(translatedData, cb); -}; - -/** - * Sign in with the given user credentials. - * - * @method verifySMSCode - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given the user credentials (`phone_number` and `code`), it will do the - * authentication on the provider and return a JSON with the `access_token` - * and `id_token`. - * - * - * var data = { - * username: '{PHONE_NUMBER}', - * password: '{VERIFICATION_CODE}' - * }; - * - * auth0.verifySMSCode(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @example - * The user data object has the following structure. - * - * - * { - * id_token: String, - * access_token: String, - * token_type: String - * } - * - * @param {Object} data Credentials object. - * @param {String} data.username Phone number. - * @param {String} data.password Verification code. - * @param {String} data.target Target client ID. - * @param {String} data.grant_type Grant type. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.verifySMSCode = function(data, cb) { - var translatedData = { - username: data.phoneNumber || data.phone_number || data.username, - password: data.code || data.password - }; - - return this.passwordless.signIn(translatedData, cb); -}; - -/** - * Exchange the token of the logged in user with a token that is valid to call - * the API (signed with the API secret). - * - * @method getDelegationToken - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given an existing token, this endpoint will generate a new token signed - * with the target client secret. This is used to flow the identity of the - * user from the application to an API or across different APIs that are - * protected with different secrets. Find more information in the - * API Docs. - * - * - * var data = { - * id_token: '{ID_TOKEN}', - * api_type: 'app', - * target: '{TARGET}', - * grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer' - * }; - * - * auth0.getDelegationToken(data, function (err, token) { - * if (err) { - * // Handle error. - * } - * - * console.log(token); - * }); - * - * @param {Object} data Token data object. - * @param {String} data.id_token The user ID token. - * @param {String} data.api_type The API type (aws, firebase, etc). - * @param {String} data.target The target client ID. - * @param {String} data.grant_type The grant type. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.getDelegationToken = function(data, cb) { - var translatedData = { - id_token: data.id_token, - api_type: data.api || data.api_type, - scope: data.scope, - target: data.targetClientId || data.target, - grant_type: data.grant_type - }; - - return this.tokens.getDelegationToken(translatedData, cb); -}; - -/** - * Change password using a database or active directory service. - * - * @method changePassword - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given the user email, the connection specified and the new password to - * use, Auth0 will send a forgot password email. Once the user clicks on the - * confirm password change link, the new password specified in this POST will - * be set to this user. Find more information in the - * - * API Docs. - * - * - * var data = { - * email: '{EMAIL}', - * password: '{PASSWORD}', - * connection: 'Username-Password-Authentication' - * }; - * - * auth0.changePassword(data, function (err, message) { - * if (err) { - * // Handle error. - * } - * - * console.log(message); - * }); - * - * @param {Object} data User data object. - * @param {String} data.email User email. - * @param {String} data.password User password. - * @param {String} data.connection Identity provider for the user. - * - * @return {Promise|undefined} - */ -AuthenticationClient.prototype.changePassword = function(data, cb) { - var translatedData = { - connection: data.connection, - email: data.email || data.username, - password: data.password - }; - - return this.database.changePassword(data, cb); -}; + getDelegationToken(data, cb) { + const translatedData = { + id_token: data.id_token, + api_type: data.api || data.api_type, + scope: data.scope, + target: data.targetClientId || data.target, + grant_type: data.grant_type, + }; + + return this.tokens.getDelegationToken(translatedData, cb); + } -/** - * Request a change password email using a database or active directory service. - * - * @method requestChangePasswordEmail - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given the user email, the connection specified, Auth0 will send a change - * password email. once the user clicks on the confirm password change link, - * the new password specified in this POST will be set to this user. Find more - * information in the + * API Docs. + * + * + * var data = { + * email: '{EMAIL}', + * password: '{PASSWORD}', + * connection: 'Username-Password-Authentication' + * }; + * + * auth0.changePassword(data, function (err, message) { + * if (err) { + * // Handle error. + * } + * + * console.log(message); + * }); + * @param {object} data User data object. + * @param {string} data.email User email. + * @param {string} data.password User password. + * @param {string} data.connection Identity provider for the user. + * @param {Function} [cb] Method callback. + * @returns {Promise|undefined} + */ + changePassword(data, cb) { + return this.database.changePassword(data, cb); + } - return this.database.requestChangePasswordEmail(data, cb); -}; + /** + * Request a change password email using a database or active directory service. + * + * @example + * Given the user email, the connection specified, Auth0 will send a change + * password email. once the user clicks on the confirm password change link, + * the new password specified in this POST will be set to this user. Find more + * information in the API Docs. - * - * - * auth0.getProfile(data, function (err, userInfo) { - * if (err) { - * // Handle error. - * } - * - * console.log(userInfo); - * }); - * - * @param {String} accessToken The user access token. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(AuthenticationClient, 'getProfile', 'users.getInfo'); + /** + * Given an access token get the user profile linked to it. + * + * @example + * Get the user information based on the Auth0 access token (obtained during + * login). Find more information in the + * API Docs. + * + * + * auth0.getProfile(data, function (err, userInfo) { + * if (err) { + * // Handle error. + * } + * + * console.log(userInfo); + * }); + * @param {string} accessToken The user access token. + * @returns {Promise|undefined} + */ + getProfile(...args) { + return this.users.getInfo(...args); + } -/** - * Gets an access token using the client credentials grant flow. - * - * @method clientCredentialsGrant - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Gets an access token using the client credentials grant flow. Find more information in the - * API Docs. - * - * - * auth0.clientCredentialsGrant({ - * audience: 'https://tenant.auth0.com/api/v2/', - * scope: 'read:users update:users' - * }, function (err, response) { - * if (err) { - * // Handle error. - * } - * - * console.log(response); - * }); - * - * @param {Object} options - * @param {String} [options.scope] scopes to request to be added to the returned access token - * @param {String} [options.audience] audience or identifier of the API where the access token will be used, e.g. Auth0 Management API - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - AuthenticationClient, - 'clientCredentialsGrant', - 'oauth.clientCredentialsGrant' -); + /** + * Gets an access token using the client credentials grant flow. + * + * @example + * Gets an access token using the client credentials grant flow. Find more information in the + * API Docs. + * + * + * auth0.clientCredentialsGrant({ + * audience: 'https://tenant.auth0.com/api/v2/', + * scope: 'read:users update:users' + * }, function (err, response) { + * if (err) { + * // Handle error. + * } + * + * console.log(response); + * }); + * @param {object} options + * @param {string} [options.scope] scopes to request to be added to the returned access token + * @param {string} [options.audience] audience or identifier of the API where the access token will be used, e.g. Auth0 Management API + * @returns {Promise|undefined} + */ + clientCredentialsGrant(...args) { + return this.oauth.clientCredentialsGrant(...args); + } -/** - * Sign in using a username and password - * - * @method passwordGrant - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given the user's credentials perform the OAuth password grant - * or Password Realm grant if a realm is provided, - * it will return a JSON with the access_token and id_token. - * More information in the - * - * API Docs - * . - * - * - * var data = { - * client_id: '{CLIENT_ID}', // Optional field. - * username: '{USERNAME}', - * password: '{PASSWORD}' - * realm: '{CONNECTION_NAME}', // Optional field. - * scope: 'openid' // Optional field. - * }; - * - * auth0.oauth.token(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} userData User credentials object. - * @param {String} userData.username Username. - * @param {String} userData.password User password. - * @param {String} [userData.realm] Name of the realm to use to authenticate or the connection name - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(AuthenticationClient, 'passwordGrant', 'oauth.passwordGrant'); + /** + * Sign in using a username and password + * + * @example + * Given the user's credentials perform the OAuth password grant + * or Password Realm grant if a realm is provided, + * it will return a JSON with the access_token and id_token. + * More information in the + * + * API Docs + * . + * + * + * var data = { + * client_id: '{CLIENT_ID}', // Optional field. + * username: '{USERNAME}', + * password: '{PASSWORD}' + * realm: '{CONNECTION_NAME}', // Optional field. + * scope: 'openid' // Optional field. + * }; + * + * auth0.passwordGrant(data, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.username Username. + * @param {string} userData.password User password. + * @param {string} [userData.realm] Name of the realm to use to authenticate or the connection name + * @param {object} [options] Additional options. + * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header + * @returns {Promise|undefined} + */ + passwordGrant(...args) { + return this.oauth.passwordGrant(...args); + } -/** - * Sign in using a refresh token - * - * @method refreshToken - * @memberOf module:auth.AuthenticationClient.prototype - * - * @example - * Given a refresh token from a previous authentication request, - * it will return a JSON with the access_token and id_token. - * More information in the - * - * API Docs - * . - * - * - * var data = { - * client_id: '{CLIENT_ID}', // Optional field. - * refresh_token: '{REFRESH_TOKEN}', - * }; - * - * auth0.refreshToken(data, function (err, userData) { - * if (err) { - * // Handle error. - * } - * - * console.log(userData); - * }); - * - * @param {Object} userData User credentials object. - * @param {String} userData.refresh_token Refresh token. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(AuthenticationClient, 'refreshToken', 'oauth.refreshToken'); + /** + * Sign in using a refresh token + * + * @example + * Given a refresh token from a previous authentication request, + * it will return a JSON with the access_token and id_token. + * More information in the + * + * API Docs + * . + * + * + * var data = { + * client_id: '{CLIENT_ID}', // Optional field. + * refresh_token: '{REFRESH_TOKEN}', + * }; + * + * auth0.refreshToken(data, function (err, userData) { + * if (err) { + * // Handle error. + * } + * + * console.log(userData); + * }); + * @param {object} userData User credentials object. + * @param {string} userData.refresh_token Refresh token. + * @returns {Promise|undefined} + */ + refreshToken(...args) { + return this.oauth.refreshToken(...args); + } +} module.exports = AuthenticationClient; diff --git a/src/errors.js b/src/errors.js new file mode 100644 index 000000000..0b53e4b08 --- /dev/null +++ b/src/errors.js @@ -0,0 +1,60 @@ +const util = require('util'); + +const errors = (module.exports = {}); + +const sanitizeErrors = function (collection) { + if (!collection) { + return; + } + + Object.keys(collection).forEach((key) => { + if (key.toLowerCase().match('password|secret|authorization')) { + collection[key] = '[REDACTED]'; + } + }); +}; + +/** + * Given a response request error, sanitize sensitive data. + * + * @param {Error} error Error object + * @returns {Error} + */ +errors.sanitizeErrorRequestData = function (error) { + if ( + !error.response || + !error.response.request || + (!error.response.request._data && !error.response.request._header) + ) { + return error; + } + + sanitizeErrors(error.response.request._header); + sanitizeErrors(error.response.request._data); + + return error; +}; + +/** + * Given an Api Error, modify the original error and sanitize + * sensitive information using sanitizeErrorRequestData + * + * @param {string} name New error name + * @param {string} message New error message + * @param {number} status New error status + * @param {any} requestInfo Request info to be attached on the error + * @param {any} originalError Original error to be attached on the error + */ +const SanitizedError = function (name, message, status, requestInfo, originalError) { + this.name = name || this.constructor.name || this.constructor.prototype.name || ''; + this.message = message || ''; + this.statusCode = status || (originalError && originalError.code); + this.requestInfo = Object.assign({}, requestInfo); + this.originalError = errors.sanitizeErrorRequestData(originalError); + + Error.captureStackTrace(this, this.constructor); +}; + +util.inherits(SanitizedError, Error); + +errors.SanitizedError = SanitizedError; diff --git a/src/index.js b/src/index.js index b36054859..ad3d0e4ca 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,11 @@ /** * Simple facade for consuming a REST API endpoint. + * * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade + * {@link https://github.com/ngonzalvez/rest-facade} */ module.exports = { ManagementClient: require('./management'), - AuthenticationClient: require('./auth') + AuthenticationClient: require('./auth'), }; diff --git a/src/management/ActionsManager.js b/src/management/ActionsManager.js new file mode 100644 index 000000000..dd5053912 --- /dev/null +++ b/src/management/ActionsManager.js @@ -0,0 +1,526 @@ +const BaseManager = require('./BaseManager'); + +/** + * {@link https://auth0.com/docs/api/v2#!/Actions/get_actions Actions} provide a way to extend + * Auth0 flows with custom logic. + * See the {@link https://auth0.com/docs/actions Actions documentation} for more information. + */ +class ActionsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the + * [Auth0 Actions endpoint]{@link https://auth0.com/docs/api/v2#!/actions}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/actions/actions/:id'); + + this.actionsDeploy = this._getRestClient('/actions/actions/:id/deploy'); + + this.actionsTest = this._getRestClient('/actions/actions/:id/test'); + + this.triggers = this._getRestClient('/actions/triggers/:trigger_id'); + + this.triggerBindings = this._getRestClient('/actions/triggers/:trigger_id/bindings'); + + this.executions = this._getRestClient('/actions/executions/:execution_id'); + + this.actionVersions = this._getRestClient('/actions/actions/:id/versions/:version_id'); + + this.actionVersionDeploy = this._getRestClient( + '/actions/actions/:id/versions/:version_id/deploy' + ); + } + + /** + * Get all Triggers. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.actions.getAllTriggers(params, function (err, actions) { + * console.log(actions.length); + * }); + * @param {object} [params] Actions parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAllTriggers(params, cb) { + params = params || {}; + + if (cb && cb instanceof Function) { + return this.triggers.getAll(params, cb); + } + + return this.triggers.getAll(params); + } + + /** + * Update the actions bound to a trigger . + * + * @example + * var data = { bindings: [{ id_type: "action_id", id_value: ACTION_ID1},{id_type: "action_name", id_value: ACTION_NAME2}]; + * var params = { trigger_id: TRIGGER_ID }; + * + * // Using auth0 instance. + * management.actions.updateTriggerBindings(params, data, function (err, bindings) { + * if (err) { + * // Handle error. + * } + * + * console.log(bindings.length); // 2 + * }); + * @param {object} params Actions Binding parameters. + * @param {string} params.trigger_id Actions Trigger ID. + * @param {object} data bindings array + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateTriggerBindings(params, data, cb) { + params = params || {}; + + if (cb && cb instanceof Function) { + return this.triggerBindings.patch(params, data, cb); + } + + return this.triggerBindings.patch(params, data); + } + + /** + * Get the actions bound to a trigger . + * + * @example + * var params = { trigger_id: TRIGGER_ID }; + * + * // Using auth0 instance. + * management.actions.getTriggerBindings(params, function (err, bindings) { + * if (err) { + * // Handle error. + * } + * + * console.log(bindings.length); // 2 + * }); + * @param {object} params Actions Binding parameters. + * @param {string} params.trigger_id Actions Trigger ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getTriggerBindings(params, cb) { + params = params || {}; + + if (cb && cb instanceof Function) { + return this.triggerBindings.getAll(params, cb); + } + + return this.triggerBindings.getAll(params); + } + + /** + * Create a new Action. + * + * @example + * management.actions.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Action created. + * }); + * @param {object} data Action data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); + } + + /** + * Get all actions. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0, + * triggerId:'TRIGGER_ID', + * actionName: 'ACTION_NAME' + * }; + * + * management.actions.getAll(params, function (err, actions) { + * console.log(actions.length); + * }); + * @param {object} [params] Actions parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {string} [params.triggerId] The trigger ID of the actions to retrieve. + * @param {string} [params.actionName] The name of the actions to retrieve. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); + } + + /** + * Get an Auth0 action. + * + * @example + * management.actions.get({ id: ACTION_ID }, function (err, action) { + * if (err) { + * // Handle error. + * } + * + * console.log(action); + * }); + * @param {object} params Action parameters. + * @param {string} params.id Action ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + get(params, cb) { + params = params || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + if (cb && cb instanceof Function) { + return this.resource.get(params, cb); + } + + return this.resource.get(params); + } + + /** + * Update an existing action. + * + * @example + * var data = { name: 'new-name' }; + * var params = { id: ACTION_ID }; + * + * // Using auth0 instance. + * management.updateAction(params, data, function (err, action) { + * if (err) { + * // Handle error. + * } + * + * console.log(action.name); // 'new-name' + * }); + * + * // Using the Actions manager directly. + * management.actions.update(params, data, function (err, action) { + * if (err) { + * // Handle error. + * } + * + * console.log(action.name); // 'new-name' + * }); + * @param {object} params Action parameters. + * @param {string} params.id Action ID. + * @param {object} data Updated action data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + update(params, data, cb) { + params = params || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + if (cb && cb instanceof Function) { + return this.resource.patch(params, data, cb); + } + + return this.resource.patch(params, data); + } + + /** + * Delete an existing action. Deleting an Action deletes all the action's versions + * + * @example + * management.actions.delete({ id: ACTION_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Action deleted. + * }); + * @param {object} params Action parameters. + * @param {string} params.id Action ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(params, cb) { + params = params || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + if (cb && cb instanceof Function) { + return this.resource.delete(params, cb); + } + + return this.resource.delete(params); + } + + /** + * test an Action. + * + * @example + * var params = { id: ACTION_ID}; + * management.actions.test(params, payload, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Action parameters. + * @param {string} params.id Action ID. + * @param {object} payload Payload represents the entire structure necessary to test a particular trigger + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + test(params, payload, cb) { + params = params || {}; + payload = payload || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + if (cb && cb instanceof Function) { + return this.actionsTest.create(params, payload, cb); + } + + return this.actionsTest.create(params, payload); + } + + /** + * deploy an Action. + * The action must be in a state of 'built' before it can be deployed. + * + * @example + * var params = { id: ACTION_ID}; + * mangement.actions.deploy(params, function (err, actionVersion) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Action parameters. + * @param {string} params.id Action ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deploy(params, cb) { + params = params || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + if (cb && cb instanceof Function) { + return this.actionsDeploy.create(params, {}, cb); + } + + return this.actionsDeploy.create(params, {}); + } + + /** + * Get all action versions + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.actions.getVersions({ id: ACTION_ID }, function (err, actionVersions) { + * console.log(actionVersions.length); + * }); + * @param {object} [params] ActionVersions parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {string} [params.id] Action ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getVersions(params, cb) { + params = params || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + if (cb && cb instanceof Function) { + return this.actionVersions.getAll(params, cb); + } + + return this.actionVersions.getAll(params); + } + + /** + * Get an Action Version. + * + * @example + * var params = { id: ACTION_ID, version_id: VERSION_ID }; + * management.actions.getVersion(params, function (err, actionVersion) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Action parameters. + * @param {string} params.id Action ID. + * @param {string} params.version_id ActionVersion ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getVersion(params, cb) { + params = params || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + if (cb && cb instanceof Function) { + return this.actionVersions.get(params, cb); + } + + return this.actionVersions.get(params); + } + + /** + * Create an Action Version. In general, updating an action and then + * deploying it is the preferred way of creating an action version, but + * this operation is supported as a way of creating versions without + * updating the action's code (which can be useful in some CI/CD scenarios). + * + * @example + * var params = { id: ACTION_ID }; + * management.actions.createActionVersion(params, data, function (err, actionVersion) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Action parameters. + * @param {string} params.id Action ID. + * @param {object} data ActionVersion parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createVersion(params, data, cb) { + params = params || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + if (cb && cb instanceof Function) { + return this.actionVersions.create(params, data, cb); + } + + return this.actionVersions.create(params, data); + } + + /** + * deploy an Action Version to roll back to a previous version. + * + * @example + * var params = { id: ACTION_ID, version_id: VERSION_ID }; + * management.actions.deployVersion(params, function (err, actionVersion) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Action parameters. + * @param {string} params.id Action ID. + * @param {string} params.version_id Action ID. + * @param {boolean} params.update_draft Update draft + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deployVersion(params, cb) { + params = params || {}; + + if (params.action_id) { + params.id = params.action_id; + delete params.action_id; + } + + const body = {}; + + if (params.update_draft) { + body.update_draft = params.update_draft; + delete params.update_draft; + } + + if (cb && cb instanceof Function) { + return this.actionVersionDeploy.create(params, body, cb); + } + + return this.actionVersionDeploy.create(params, body); + } + + /** + * Get an execution by ID. + * + * @example + * management.actions.getExecution({ execution_id: EXECUTION_ID }, function (err, action) { + * if (err) { + * // Handle error. + * } + * + * console.log(ActionExecution); + * }); + * @param {object} params Action Execution parameters. + * @param {string} params.id Action Execution ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getExecution(params, cb) { + params = params || {}; + + if (cb && cb instanceof Function) { + return this.executions.get(params, cb); + } + + return this.executions.get(params); + } +} + +module.exports = ActionsManager; diff --git a/src/management/AttackProtectionManager.js b/src/management/AttackProtectionManager.js new file mode 100644 index 000000000..6edba6787 --- /dev/null +++ b/src/management/AttackProtectionManager.js @@ -0,0 +1,158 @@ +const BaseManager = require('./BaseManager'); + +/** + * Simple facade for consuming a REST API endpoint. + * + * @external RestClient + * @see https://github.com/ngonzalvez/rest-facade + */ + +class AttackProtectionManager extends BaseManager { + /** + * @class + * Abstracts interaction with the attack-protection endpoints. + * @class + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + * @param {object} [options.tokenProvider] Management API Token Provider + */ + constructor(options) { + super(options); + + this.bruteForceProtection = this._getRestClient('/attack-protection/brute-force-protection'); + + this.suspiciousIpThrottling = this._getRestClient( + '/attack-protection/suspicious-ip-throttling' + ); + + this.breachedPasswordDetection = this._getRestClient( + '/attack-protection/breached-password-detection' + ); + } + + /** + * Get the Brute Force Protection configuration. + * + * @example + * management.attackProtection.getBruteForceConfig(params, function (err, bruteForceConfig) { + * if (err) { + * // Handle error. + * } + * + * // Brute force config + * console.log(bruteForceConfig); + * }); + * @param {object} params Brute force parameters (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getBruteForceConfig(...args) { + return this.bruteForceProtection.get(...args); + } + + /** + * Update the Brute Force Protection configuration. + * + * @example + * management.attackProtection.updateBruteForceConfig(params, data, function (err, bruteForceConfig) { + * if (err) { + * // Handle error. + * } + * + * // Brute force config + * console.log(bruteForceConfig); + * }); + * @param {object} params Brute force parameters (leave empty). + * @param {object} data Updated brute force configuration. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateBruteForceConfig(...args) { + return this.bruteForceProtection.patch(...args); + } + + /** + * Get the Suspicious IP Throttling configuration. + * + * @example + * management.attackProtection.getSuspiciousIpThrottlingConfig(params, function (err, suspiciousIpThrottlingConfig) { + * if (err) { + * // Handle error. + * } + * + * // Access suspicious IP throttling configuration + * console.log(suspiciousIpThrottlingConfig); + * }); + * @param {object} params Suspicious IP throttling parameters (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getSuspiciousIpThrottlingConfig(...args) { + return this.suspiciousIpThrottling.get(...args); + } + + /** + * Update the Suspicious IP Throttling configuration. + * + * @example + * management.attackProtection.updateSuspiciousIpThrottlingConfig(params, data, function (err, suspiciousIpThrottlingConfig) { + * if (err) { + * // Handle error. + * } + * + * // Access suspicious IP throttling configuration + * console.log(suspiciousIpThrottlingConfig); + * }); + * @param {object} params Suspicious IP throttling parameters (leave empty). + * @param {object} data Updated suspicious IP throttling configuration. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateSuspiciousIpThrottlingConfig(...args) { + return this.suspiciousIpThrottling.patch(...args); + } + + /** + * Get the Breached Password Detection configuration. + * + * @example + * management.attackProtection.getBreachedPasswordDetectionConfig(params, function (err, breachedPasswordDetectionConfig) { + * if (err) { + * // Handle error. + * } + * + * // Access breached password detection configuration + * console.log(breachedPasswordDetectionConfig); + * }); + * @param {object} params Breached password detection parameters (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getBreachedPasswordDetectionConfig(...args) { + return this.breachedPasswordDetection.get(...args); + } + + /** + * Update the breached password detection configuration. + * + * @example + * management.attackProtection.updateBreachedPasswordDetectionConfig(params, data, function (err, breachedPasswordDetectionConfig) { + * if (err) { + * // Handle error. + * } + * + * // Access breached password detection configuration + * console.log(breachedPasswordDetectionConfig); + * }); + * @param {object} params Breached password detection parameters (leave empty). + * @param {object} data Updated breached password detection configuration. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateBreachedPasswordDetectionConfig(...args) { + return this.breachedPasswordDetection.patch(...args); + } +} +module.exports = AttackProtectionManager; diff --git a/src/management/BaseManager.js b/src/management/BaseManager.js new file mode 100644 index 000000000..248b707fe --- /dev/null +++ b/src/management/BaseManager.js @@ -0,0 +1,41 @@ +const { ArgumentError } = require('rest-facade'); +const Auth0RestClient = require('../Auth0RestClient'); +const RetryRestClient = require('../RetryRestClient'); + +class BaseManager { + constructor(options) { + if (options === null || typeof options !== 'object') { + throw new ArgumentError('Must provide manager options'); + } + + if (options.baseUrl === null || options.baseUrl === undefined) { + throw new ArgumentError('Must provide a base URL for the API'); + } + + if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { + throw new ArgumentError('The provided base URL is invalid'); + } + + this._options = options; + } + + _getRestClient(path) { + const options = this._options; + const clientOptions = { + errorFormatter: { message: 'message', name: 'error' }, + headers: options.headers, + proxy: options.proxy, + query: { repeatParams: false }, + includeResponseHeaders: options.includeResponseHeaders, + }; + + const usersAuth0RestClient = new Auth0RestClient( + `${options.baseUrl}${path}`, + clientOptions, + options.tokenProvider + ); + return new RetryRestClient(usersAuth0RestClient, options.retry); + } +} + +module.exports = BaseManager; diff --git a/src/management/BlacklistedTokensManager.js b/src/management/BlacklistedTokensManager.js index 9da308df4..3206eb88b 100644 --- a/src/management/BlacklistedTokensManager.js +++ b/src/management/BlacklistedTokensManager.js @@ -1,102 +1,67 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * @class BlacklistedTokensManager * The BlacklistedTokensManager class provides methods to retrieve the list of * blacklisted tokens and blacklist new ones.. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var BlacklistedTokensManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide client options'); - } - - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); - } +class BlacklistedTokensManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Provides an abstraction layer for consuming the + * [Auth0 Blacklisted Tokens endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/blacklists/tokens'); } /** - * Options object for the Rest Client instace. + * Blacklist a new token. + * + * @example + * var token = { + * aud: 'aud', + * jti: 'jti' + * }; * - * @type {Object} + * management.blacklistedTokens.add(token, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Token blacklisted. + * }); + * @param {object} token Token data. + * @param {string} token.aud Audience (your app client ID). + * @param {string} token.jti The JWT ID claim. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + add(...args) { + return this.resource.create(...args); + } /** - * Provides an abstraction layer for consuming the - * [Auth0 Blacklisted Tokens endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}. + * Get all blacklisted tokens. * - * @type {external:RestClient} + * @example + * management.blacklistedTokens.getAll(function (err, tokens) { + * console.log(tokens.length); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/blacklists/tokens', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Blacklist a new token. - * - * @method add - * @memberOf module:management.BlacklistedTokensManager.prototype - * - * @example - * var token = { - * aud: 'aud', - * jti: 'jti' - * }; - * - * management.blacklistedTokens.add(token, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Token blacklisted. - * }); - * - * @param {Object} token Token data. - * @param {String} token.aud Audience (your app client ID). - * @param {String} token.jti The JWT ID claim. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(BlacklistedTokensManager, 'add', 'resource.create'); - -/** - * Get all blacklisted tokens. - * - * @method getAll - * @memberOf module:management.BlacklistedTokensManager.prototype - * - * @example - * management.blacklistedTokens.getAll(function (err, tokens) { - * console.log(tokens.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(BlacklistedTokensManager, 'getAll', 'resource.getAll'); + getAll(...args) { + return this.resource.getAll(...args); + } +} module.exports = BlacklistedTokensManager; diff --git a/src/management/BrandingManager.js b/src/management/BrandingManager.js new file mode 100644 index 000000000..abe51162c --- /dev/null +++ b/src/management/BrandingManager.js @@ -0,0 +1,250 @@ +const BaseManager = require('./BaseManager'); + +/** + * Manages settings related to branding. + */ +class BrandingManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/management/v2#!/Branding Branding endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/branding'); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/management/v2#!/Branding/get_universal_login Branding new universal login template endpoint}. + * + * @type {external:RestClient} + */ + this.brandingTemplates = this._getRestClient('/branding/templates/universal-login'); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/management/v2#!/Branding/get_branding_theme Branding theme endpoint}. + * + * @type {external:RestClient} + */ + this.brandingThemes = this._getRestClient('/branding/themes/:id'); + } + + /** + * Update the branding settings. + * + * @example + * management.branding.updateSettings(params, data, function (err, branding) { + * if (err) { + * // Handle error. + * } + * + * // Updated branding + * console.log(branding); + * }); + * @param {object} params Branding parameters (leavy empty). + * @param {object} data Updated branding data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateSettings(...args) { + return this.resource.patch(...args); + } + + /** + * Get the branding settings.. + * + * @example + * management.branding.getSettings(data, function (err, branding) { + * if (err) { + * // Handle error. + * } + * + * // Branding + * console.log(branding); + * }); + * @param {object} params Branding parameters. + * @param {object} data Branding data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getSettings(...args) { + return this.resource.get(...args); + } + + /** + * Get the new universal login template. + * + * @example + * management.branding.getUniversalLoginTemplate(data, function (err, template) { + * if (err) { + * // Handle error. + * } + * + * // Branding + * console.log(template); + * }); + * @param {object} params Branding parameters (leave empty). + * @param {object} data Branding data (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUniversalLoginTemplate(...args) { + return this.brandingTemplates.get(...args); + } + + /** + * Set the new universal login template. + * + * @example + * management.branding.setUniversalLoginTemplate(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Branding parameters (leavy empty). + * @param {object} data Branding data (object with template field). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + setUniversalLoginTemplate(...args) { + return this.brandingTemplates.update(...args); + } + + /** + * Delete the new universal login template (revert to default). + * + * @example + * management.branding.deleteUniversalLoginTemplate(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Branding parameters (leavy empty). + * @param {object} data Branding data (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteUniversalLoginTemplate(...args) { + return this.brandingTemplates.delete(...args); + } + + /** + * Get the new universal login theme by id. + * + * @example + * var params = { id: THEME_ID }; + * + * management.branding.getTheme(params, function (err, theme) { + * if (err) { + * // Handle error. + * } + * + * // Theme + * console.log(theme); + * }); + * @param {object} params Theme params + * @param {object} params.id Theme identifier. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getTheme(...args) { + return this.brandingThemes.get(...args); + } + + /** + * Get the default new universal login theme. + * + * @example + * management.branding.getDefaultTheme(function (err, theme) { + * if (err) { + * // Handle error. + * } + * + * // Theme + * console.log(theme); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getDefaultTheme(...args) { + return this.brandingThemes.get(...[{ id: 'default' }].concat(args)); + } + + /** + * Create a new theme. + * + * @example + * management.branding.createTheme(data, function (err, theme) { + * if (err) { + * // Handle error. + * } + * + * // Theme created. + * console.log(theme); + * }); + * @param {object} data theme data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createTheme(...args) { + return this.brandingThemes.create(...args); + } + + /** + * Update a theme. + * + * @example + * var data = THEME_OBJ; + * var params = { id: THEME_ID }; + * + * management.branding.updateTheme(params, data, function (err, theme) { + * if (err) { + * // Handle error. + * } + * + * // Theme updated. + * console.log(theme); + * }); + * @param {object} params Theme parameters. + * @param {object} params.id Theme identifier. + * @param {object} data Updated theme data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateTheme(...args) { + return this.brandingThemes.patch(...args); + } + + /** + * Delete a theme. + * + * @example + * var params = { id: THEME_ID }; + * + * management.branding.deleteTheme(params, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Theme deleted. + * }); + * @param {object} params Theme parameters. + * @param {object} params.id Theme identifier. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteTheme(...args) { + return this.brandingThemes.delete(...args); + } +} + +module.exports = BrandingManager; diff --git a/src/management/ClientGrantsManager.js b/src/management/ClientGrantsManager.js index 7cafa6df3..b93825f41 100644 --- a/src/management/ClientGrantsManager.js +++ b/src/management/ClientGrantsManager.js @@ -1,165 +1,124 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); + /** - * @class ClientGrantsManager * Auth0 Client Grants Manager. * * See {@link https://auth0.com/docs/api/v2#!/Client_Grants Client Grants} - * - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var ClientGrantsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide client options'); - } +class ClientGrantsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Client_Grants Auth0 Client Grants endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/client-grants/:id'); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Create an Auth0 client grant. + * + * @example + * management.clientGrants.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Client grant created. + * }); + * @param {object} data The client data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); } /** - * Options object for the Rest Client instance. + * Get all Auth0 Client Grants. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * * - * @type {Object} + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * + * management.clientGrants.getAll(params, function (err, grants) { + * console.log(grants.length); + * }); + * @param {object} [params] Client Grants parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + getAll(...args) { + return this.resource.getAll(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Client_Grants Auth0 Client Grants endpoint}. + * Update an Auth0 client grant. * - * @type {external:RestClient} + * @example + * var data = { + * client_id: CLIENT_ID, + * audience: AUDIENCE, + * scope: [] + * }; + * var params = { id: CLIENT_GRANT_ID }; + * + * management.clientGrants.update(params, data, function (err, grant) { + * if (err) { + * // Handle error. + * } + * + * console.log(grant.id); + * }); + * @param {object} params Client parameters. + * @param {string} params.id Client grant ID. + * @param {object} data Updated client data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/client-grants/:id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Create an Auth0 client grant. - * - * @method create - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * management.clientGrants.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client grant created. - * }); - * - * @param {Object} data The client data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientGrantsManager, 'create', 'resource.create'); - -/** - * Get all Auth0 Client Grants. - * - * @method getAll - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * - * management.clientGrants.getAll(params, function (err, grants) { - * console.log(grants.length); - * }); - * - * @param {Object} [params] Client Grants parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientGrantsManager, 'getAll', 'resource.getAll'); - -/** - * Update an Auth0 client grant. - * - * @method update - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * var data = { - * client_id: CLIENT_ID, - * audience: AUDIENCE, - * scope: [] - * }; - * var params = { id: CLIENT_GRANT_ID }; - * - * management.clientGrants.update(params, data, function (err, grant) { - * if (err) { - * // Handle error. - * } - * - * console.log(grant.id); - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.id Client grant ID. - * @param {Object} data Updated client data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientGrantsManager, 'update', 'resource.patch'); + update(...args) { + return this.resource.patch(...args); + } -/** - * Delete an Auth0 client grant. - * - * @method delete - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * management.clientGrants.delete({ id: GRANT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Grant deleted. - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.id Client grant ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientGrantsManager, 'delete', 'resource.delete'); + /** + * Delete an Auth0 client grant. + * + * @example + * management.clientGrants.delete({ id: GRANT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Grant deleted. + * }); + * @param {object} params Client parameters. + * @param {string} params.id Client grant ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } +} module.exports = ClientGrantsManager; diff --git a/src/management/ClientsManager.js b/src/management/ClientsManager.js index 4acf3ce3a..7c1045abb 100644 --- a/src/management/ClientsManager.js +++ b/src/management/ClientsManager.js @@ -1,10 +1,7 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); /** - * @class ClientsManager * Auth0 Clients Manager. * * {@link https://auth0.com/docs/api/v2#!/Clients Clients} represent @@ -12,176 +9,176 @@ var RetryRestClient = require('../RetryRestClient'); * You can learn more about this in the * {@link https://auth0.com/docs/applications Applications} section of the * documentation. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var ClientsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide client options'); +class ClientsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Clients Auth0 Clients endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/clients/:client_id'); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/management/v2#!/Clients/post_rotate_secret Auth0 Clients Rotate a client secret}. + * + * @type {external:RestClient} + */ + this.rotateSecretResource = this._getRestClient('/clients/:client_id/rotate-secret'); } - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Create an Auth0 client. + * + * @example + * management.clients.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Client created. + * }); + * @param {object} data The client data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Get all Auth0 clients. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.clients.getAll(params, function (err, clients) { + * console.log(clients.length); + * }); + * @param {object} [params] Clients parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); } /** - * Options object for the Rest Client instance. + * Get an Auth0 client. + * + * @example + * management.clients.get({ client_id: CLIENT_ID }, function (err, client) { + * if (err) { + * // Handle error. + * } * - * @type {Object} + * console.log(client); + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {string} params.fields Comma-separated list of fields to include or exclude (based on value provided for include_fields). + * @param {string} params.include_fields Whether specified fields are to be included (true) or excluded (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + get(...args) { + return this.resource.get(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Clients Auth0 Clients endpoint}. + * Update an Auth0 client. + * + * @example + * var data = { name: 'newClientName' }; + * var params = { client_id: CLIENT_ID }; * - * @type {external:RestClient} + * management.clients.update(params, data, function (err, client) { + * if (err) { + * // Handle error. + * } + * + * console.log(client.name); // 'newClientName' + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {object} data Updated client data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/clients/:client_id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; + update(...args) { + return this.resource.patch(...args); + } -/** - * Create an Auth0 client. - * - * @method create - * @memberOf module:management.ClientsManager.prototype - * - * @example - * management.clients.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client created. - * }); - * - * @param {Object} data The client data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'create', 'resource.create'); + /** + * Delete an Auth0 client. + * + * @example + * management.clients.delete({ client_id: CLIENT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Client deleted. + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } -/** - * Get all Auth0 clients. - * - * @method getAll - * @memberOf module:management.ClientsManager.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.clients.getAll(params, function (err, clients) { - * console.log(clients.length); - * }); - * - * @param {Object} [params] Clients parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'getAll', 'resource.getAll'); + /** + * Rotate a client secret + * + * @example + * management.clients.rotateClientSecret({ client_id: CLIENT_ID }, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Client secret rotated. + * }); + * @param {object} params params object + * @param {string} params.client_id Application client ID. + * @returns {Promise|undefined} + */ + rotateClientSecret(params, cb) { + const query = params || {}; -/** - * Get an Auth0 client. - * - * @method get - * @memberOf module:management.ClientsManager.prototype - * - * @example - * management.clients.get({ client_id: CLIENT_ID }, function (err, client) { - * if (err) { - * // Handle error. - * } - * - * console.log(client); - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'get', 'resource.get'); + // Require a client ID. + if (!params.client_id) { + throw new ArgumentError('The client_id cannot be null or undefined'); + } -/** - * Update an Auth0 client. - * - * @method update - * @memberOf module:management.ClientsManager.prototype - * - * @example - * var data = { name: 'newClientName' }; - * var params = { client_id: CLIENT_ID }; - * - * management.clients.update(params, data, function (err, client) { - * if (err) { - * // Handle error. - * } - * - * console.log(client.name); // 'newClientName' - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Object} data Updated client data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'update', 'resource.patch'); + if (cb && cb instanceof Function) { + return this.rotateSecretResource.create(query, {}, cb); + } -/** - * Delete an Auth0 client. - * - * @method delete - * @memberOf module:management.ClientsManager.prototype - * - * @example - * management.clients.delete({ client_id: CLIENT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client deleted. - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ClientsManager, 'delete', 'resource.delete'); + return this.rotateSecretResource.create(query, {}); + } +} module.exports = ClientsManager; diff --git a/src/management/ConnectionsManager.js b/src/management/ConnectionsManager.js index c7925450b..f63420e6a 100644 --- a/src/management/ConnectionsManager.js +++ b/src/management/ConnectionsManager.js @@ -1,181 +1,208 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); /** - * @class ConnectionsManager * Represents the relationship between Auth0 and an Identity provider. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var ConnectionsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide client options'); +class ConnectionsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/v2#!/ConnectionsManagers Auth0 + * Connections}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/connections/:id'); + + this.status = this._getRestClient('/connections/:id/status'); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/management/v2#!/Connections/delete_users_by_email + * endpoint}. + * + * @type {external:RestClient} + */ + this.user = this._getRestClient('/connections/:id/users'); } - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Create a new connection. + * + * @example + * management.connections.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Connection created. + * }); + * @param {object} data Connection data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Get all connections. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.connections.getAll(params, function (err, connections) { + * console.log(connections.length); + * }); + * @param {object} [params] Connections params. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); } /** - * Options object for the Rest Client instance. + * Get an Auth0 connection. + * + * @example + * management.connections.get({ id: CONNECTION_ID }, function (err, connection) { + * if (err) { + * // Handle error. + * } * - * @type {Object} + * console.log(connection); + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - headers: options.headers, - query: { repeatParams: false } - }; + get(...args) { + return this.resource.get(...args); + } /** - * Provides an abstraction layer for performing CRUD operations on - * {@link https://auth0.com/docs/api/v2#!/ConnectionsManagers Auth0 - * Connections}. + * Update an existing connection. + * + * @example + * var data = { name: 'newConnectionName' }; + * var params = { id: CONNECTION_ID }; + * + * management.connections.update(params, data, function (err, connection) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * console.log(connection.name); // 'newConnectionName' + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {object} data Updated connection data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/connections/:id ', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; + update(...args) { + return this.resource.patch(...args); + } -/** - * Create a new connection. - * - * @method create - * @memberOf module:management.ConnectionsManager.prototype - * - * @example - * management.connections.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Conection created. - * }); - * - * @param {Object} data Connection data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ConnectionsManager, 'create', 'resource.create'); + /** + * Delete an existing connection. + * + * @example + * management.connections.delete({ id: CONNECTION_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Connection deleted. + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } -/** - * Get all connections. - * - * @method getAll - * @memberOf module:management.ConnectionsManager.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.connections.getAll(params, function (err, connections) { - * console.log(connections.length); - * }); - * - * @param {Object} [params] Connections params. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ConnectionsManager, 'getAll', 'resource.getAll'); + /** + * Checks the status of an ad/ldap connection referenced by its ID. + * + * @example + * var params = {id : 'CONNECTION_ID'} + * @example + * This methods takes the connection ID and returns the status when online, or an error when offline. + * + * + * management.connections.checkStatus( {id : 'CONNECTION_ID'}, function (err, status) { + * if (err) { + * console.log('OFFLINE', err); + * } else { + * console.log('ONLINE', status); + * } + * }); + * @param {object} params Connection parameters + * @param {string} params.id ID of the Connection. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + checkStatus(...args) { + return this.status.get(...args); + } -/** - * Get an Auth0 connection. - * - * @method get - * @memberOf module:management.ConnectionsManager.prototype - * - * @example - * management.connections.get({ id: CONNECTION_ID }, function (err, connection) { - * if (err) { - * // Handle error. - * } - * - * console.log(connection); - * }); - * - * @param {Object} params Connection parameters. - * @param {String} params.id Connection ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ConnectionsManager, 'get', 'resource.get'); + /** + * Delete a connection user by email. + * + * @example + * management.connections.deleteUserByEmail({ id: CONNECTION_ID, email:USER_EMAIL }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User deleted. + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {string} params.email User Email. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteUserByEmail(params, cb) { + if (typeof params !== 'object' || typeof params.email !== 'string' || params.email.length < 1) { + throw new ArgumentError('You must provide an email for the deleteUserByEmail method'); + } -/** - * Update an existing connection. - * - * @method update - * @memberOf module:management.ConnectionsManager.prototype - * - * @example - * var data = { name: 'newConnectionName' }; - * var params = { id: CONNECTION_ID }; - * - * management.connections.update(params, data, function (err, connection) { - * if (err) { - * // Handle error. - * } - * - * console.log(connection.name); // 'newConnectionName' - * }); - * - * @param {Object} params Conneciton parameters. - * @param {String} params.id Connection ID. - * @param {Object} data Updated connection data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ConnectionsManager, 'update', 'resource.patch'); + if (!params.id) { + throw new ArgumentError('The connection id cannot be null or undefined'); + } -/** - * Delete an existing connection. - * - * @method delete - * @memberOf module:management.ConnectionsManager.prototype - * - * @example - * management.connections.delete({ id: CONNECTION_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Conection deleted. - * }); - * - * @param {Object} params Connection parameters. - * @param {String} params.id Connection ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ConnectionsManager, 'delete', 'resource.delete'); + if (cb && cb instanceof Function) { + return this.user.delete(params, {}, cb); + } + + return this.user.delete(params, {}); + } +} module.exports = ConnectionsManager; diff --git a/src/management/CustomDomainsManager.js b/src/management/CustomDomainsManager.js index fea099afc..d7825cf71 100644 --- a/src/management/CustomDomainsManager.js +++ b/src/management/CustomDomainsManager.js @@ -1,10 +1,7 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); /** - * @class CustomDomainsManager * Auth0 Custom Domains Manager. * * {@link https://auth0.com/docs/api/management/v2#!/Custom_Domains/get_custom_domains CustomDomains} represent @@ -12,179 +9,133 @@ var RetryRestClient = require('../RetryRestClient'); * You can learn more about this in the * {@link https://auth0.com/docs/custom-domains CustomDomains} section of the * documentation. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var CustomDomainsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); - } +class CustomDomainsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); - } + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/custom-domains/:id'); - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains Verify endpoint}. + * + * @type {external:RestClient} + */ + this.vefifyResource = this._getRestClient('/custom-domains/:id/verify'); } /** - * Options object for the Rest Client instance. + * Create an Auth0 Custom Domain. + * + * @example + * management.customDomains.create(data, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {Object} + * // CustomDomain created. + * }); + * @param {object} data The custom domain data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + create(...args) { + return this.resource.create(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains endpoint}. + * Get all Auth0 CustomDomains. * - * @type {external:RestClient} + * @example + * management.customDomains.getAll(function (err, customDomains) { + * console.log(customDomains.length); + * }); + * @returns {Promise|undefined} */ - var auth0CustomDomainsRestClient = new Auth0RestClient( - options.baseUrl + '/custom-domains/:id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0CustomDomainsRestClient, options.retry); + getAll(...args) { + return this.resource.getAll(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Custom_Domains Auth0 Custom Domains Verify endpoint}. + * Get a Custom Domain. + * + * @example + * management.customDomains.get({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * console.log(customDomain); + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0VerifyRestClient = new Auth0RestClient( - options.baseUrl + '/custom-domains/:id/verify', - clientOptions, - options.tokenProvider - ); - this.vefifyResource = new RetryRestClient(auth0VerifyRestClient, options.retry); -}; - -/** - * Create an Auth0 Custom Domain. - * - * @method create - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // CustomDomain created. - * }); - * - * @param {Object} data The custom domain data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(CustomDomainsManager, 'create', 'resource.create'); + get(...args) { + return this.resource.get(...args); + } -/** - * Get all Auth0 CustomDomains. - * - * @method getAll - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.getAll(function (err, customDomains) { - * console.log(customDomains.length); - * }); - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(CustomDomainsManager, 'getAll', 'resource.getAll'); + /** + * Verify a Custom Domain. + * + * @example + * management.customDomains.verify({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { + * if (err) { + * // Handle error. + * } + * + * console.log(customDomain); + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + verify(params, cb) { + if (!params || !params.id) { + throw new ArgumentError('The custom domain id cannot be null or undefined'); + } -/** - * Get a Custom Domain. - * - * @method get - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.get({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { - * if (err) { - * // Handle error. - * } - * - * console.log(customDomain); - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(CustomDomainsManager, 'get', 'resource.get'); + if (cb && cb instanceof Function) { + return this.vefifyResource.create(params, {}, cb); + } -/** - * Verify a Custom Domain. - * - * @method verify - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.verify({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { - * if (err) { - * // Handle error. - * } - * - * console.log(customDomain); - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -CustomDomainsManager.prototype.verify = function(params, cb) { - if (!params || !params.id) { - throw new ArgumentError('The custom domain id cannot be null or undefined'); + return this.vefifyResource.create(params, {}); } - if (cb && cb instanceof Function) { - return this.vefifyResource.create(params, {}, cb); + /** + * Delete a Custom Domain. + * + * @example + * management.customDomains.delete({ id: CUSTOM_DOMAIN_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // CustomDomain deleted. + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); } - - return this.vefifyResource.create(params, {}); -}; - -/** - * Delete a Custom Domain. - * - * @method delete - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.customDomains.delete({ id: CUSTOM_DOMAIN_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // CustomDomain deleted. - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(CustomDomainsManager, 'delete', 'resource.delete'); +} module.exports = CustomDomainsManager; diff --git a/src/management/DeviceCredentialsManager.js b/src/management/DeviceCredentialsManager.js index af97301a5..0d78b8dab 100644 --- a/src/management/DeviceCredentialsManager.js +++ b/src/management/DeviceCredentialsManager.js @@ -1,126 +1,91 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - -/** - * @class DeviceCredentialsManager * Manages Auth0 Device Credentials. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var DeviceCredentialsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); - } +class DeviceCredentialsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); - } + /** + * Options object for the RestClient instance. + * + * @type {object} + */ - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Device_Credentials + * Auth0 DeviceCredentialsManagers endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/device-credentials/:id'); } /** - * Options object for the RestClient instance. + * Create an Auth0 credential. * - * @type {Object} + * @example + * management.deviceCredentials.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Credential created. + * }); + * @param {object} data The device credential data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + createPublicKey(...args) { + return this.resource.create(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Device_Credentials - * Auth0 DeviceCredentialsManagers endpoint}. + * Get all Auth0 credentials. + * + * @example + * var params = {user_id: "USER_ID"}; * - * @type {external:RestClient} + * management.deviceCredentials.getAll(params, function (err, credentials) { + * console.log(credentials.length); + * }); + * @param {object} params Credential parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/device-credentials/:id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Create an Auth0 credential. - * - * @method create - * @memberOf module:management.DeviceCredentialsManager.prototype - * - * @example - * management.deviceCredentials.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Credential created. - * }); - * - * @param {Object} data The device credential data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(DeviceCredentialsManager, 'createPublicKey', 'resource.create'); - -/** - * Get all Auth0 credentials. - * - * @method getAll - * @memberOf module:management.DeviceCredentialsManager.prototype - * - * @example - * management.deviceCredentials.getAll(function (err, credentials) { - * console.log(credentials.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(DeviceCredentialsManager, 'getAll', 'resource.getAll'); + getAll(...args) { + return this.resource.getAll(...args); + } -/** - * Delete an Auth0 device credential. - * - * @method delete - * @memberOf module:management.DeviceCredentialsManager.prototype - * - * @example - * var params = { id: CREDENTIAL_ID }; - * - * management.deviceCredentials.delete(params, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Credential deleted. - * }); - * - * @param {Object} params Credential parameters. - * @param {String} params.id Device credential ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(DeviceCredentialsManager, 'delete', 'resource.delete'); + /** + * Delete an Auth0 device credential. + * + * @example + * var params = { id: CREDENTIAL_ID }; + * + * management.deviceCredentials.delete(params, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Credential deleted. + * }); + * @param {object} params Credential parameters. + * @param {string} params.id Device credential ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } +} module.exports = DeviceCredentialsManager; diff --git a/src/management/EmailProviderManager.js b/src/management/EmailProviderManager.js index 591d9aea5..ecc63d107 100644 --- a/src/management/EmailProviderManager.js +++ b/src/management/EmailProviderManager.js @@ -1,144 +1,101 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - -/** - * @class EmailProviderManager * Auth0 Email Provider. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var EmailProviderManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide client options'); - } +class EmailProviderManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Provides an abstraction layer for consuming the + * [Auth0 Clients endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/emails/provider'); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Configure the email provider. + * + * @example + * management.emailProvider.configure(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email provider configured. + * }); + * @param {object} data The email provider data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + configure(...args) { + return this.resource.create(...args); } /** - * Options object for the Rest Client instance. + * Get the email provider. * - * @type {Object} + * @example + * management.emailProvider.get(function (err, provider) { + * console.log(provider); + * }); + * @param {Function} [cb] Callback function. + * @param {object} [params] Clients parameters. + * @param {number} [params.fields] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields. + * @param {number} [params.include_fields] true if the fields specified are to be excluded from the result, false otherwise (defaults to true) + * @returns {Promise|undefined} */ - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + get(...args) { + return this.resource.getAll(...args); + } /** - * Provides an abstraction layer for consuming the - * [Auth0 Clients endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}. + * Update the email provider. + * + * @example + * management.emailProvider.update(params, data, function (err, provider) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * // Updated email provider. + * console.log(provider); + * }); + * @param {object} params Email provider parameters. + * @param {object} data Updated email provider data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/emails/provider', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Configure the email provider. - * - * @method configure - * @memberOf module:management.EmailProviderManager.prototype - * - * @example - * management.emailProvider.configure(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email provider configured. - * }); - * @param {Object} data The email provider data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(EmailProviderManager, 'configure', 'resource.create'); - -/** - * Get the email provider. - * - * @method get - * @memberOf module:management.EmailProviderManager.prototype - * - * @example - * management.emailProvider.get(function (err, provider) { - * console.log(provider); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(EmailProviderManager, 'get', 'resource.getAll'); - -/** - * Update the email provider. - * - * @method update - * @memberOf module:management.EmailProviderManager.prototype - * - * @example - * management.emailProvider.update(params, data, function (err, provider) { - * if (err) { - * // Handle error. - * } - * - * // Updated email provider. - * console.log(provider); - * }); - * - * @param {Object} params Email provider parameters. - * @param {Object} data Updated email provider data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(EmailProviderManager, 'update', 'resource.patch'); + update(...args) { + return this.resource.patch(...args); + } -/** - * Delete email provider. - * - * @method delete - * @memberOf module:management.EmailProviderManager.prototype - * - * @example - * management.emailProvider.delete(function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email provider configured. - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(EmailProviderManager, 'delete', 'resource.delete'); + /** + * Delete email provider. + * + * @example + * management.emailProvider.delete(function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email provider configured. + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } +} module.exports = EmailProviderManager; diff --git a/src/management/EmailTemplatesManager.js b/src/management/EmailTemplatesManager.js index c92ea85c8..45e94ce07 100644 --- a/src/management/EmailTemplatesManager.js +++ b/src/management/EmailTemplatesManager.js @@ -1,129 +1,90 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - -/** - * @class EmailTemplatesManager * This class provides a simple abstraction for performing CRUD operations - * on Auth0's Email Templates. {@see https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName} - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config + * on Auth0's Email Templates. {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName} */ -var EmailTemplatesManager = function(options) { - if (!options || 'object' !== typeof options) { - throw new ArgumentError('Must provide manager options'); - } +class EmailTemplatesManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if (!options.baseUrl || 'string' !== typeof options.baseUrl) { - throw new ArgumentError('Must provide a valid string as base URL for the API'); + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName Auth0's Email Templates}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/email-templates/:name'); } /** - * Options object for the Rest Client instance. + * Create a new Email Template. * - * @type {Object} + * @example + * management.emailTemplates.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email Template created. + * }); + * @param {object} data Email Template data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - headers: options.headers, - query: { repeatParams: false } - }; + create(...args) { + return this.resource.create(...args); + } /** - * Provides an abstraction layer for performing CRUD operations on - * {@link https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName Auth0's Email Templates}. + * Get an Auth0 Email Template. + * + * @example + * management.emailTemplates.get({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * console.log(emailTemplate); + * }); + * @param {object} params Email Template parameters. + * @param {string} params.name Template Name + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/email-templates/:name', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Create a new Email Template. - * - * @method create - * @memberOf module:management.EmailTemplatesManager.prototype - * - * @example - * management.emailTemplates.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email Template created. - * }); - * - * @param {Object} data Email Template data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(EmailTemplatesManager, 'create', 'resource.create'); - -/** - * Get an Auth0 Email Template. - * - * @method get - * @memberOf module:management.EmailTemplatesManager.prototype - * - * @example - * management.emailTemplates.get({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) { - * if (err) { - * // Handle error. - * } - * - * console.log(emailTemplate); - * }); - * - * @param {Object} params Email Template parameters. - * @param {String} params.name Template Name - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(EmailTemplatesManager, 'get', 'resource.get'); + get(...args) { + return this.resource.get(...args); + } -/** - * Update an existing Email Template. - * - * @method update - * @memberOf module:management.EmailTemplatesManager.prototype - * - * @example - * var data = { from: 'new@email.com' }; - * var params = { name: EMAIL_TEMPLATE_NAME }; - * - * management.emailTemplates.update(params, data, function (err, emailTemplate) { - * if (err) { - * // Handle error. - * } - * - * console.log(emailTemplate.from); // 'new@email.com' - * }); - * - * @param {Object} params Email Template parameters. - * @param {String} params.name Template Name - * @param {Object} data Updated Email Template data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(EmailTemplatesManager, 'update', 'resource.patch'); + /** + * Update an existing Email Template. + * + * @example + * var data = { from: 'new@email.com' }; + * var params = { name: EMAIL_TEMPLATE_NAME }; + * + * management.emailTemplates.update(params, data, function (err, emailTemplate) { + * if (err) { + * // Handle error. + * } + * + * console.log(emailTemplate.from); // 'new@email.com' + * }); + * @param {object} params Email Template parameters. + * @param {string} params.name Template Name + * @param {object} data Updated Email Template data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + update(...args) { + return this.resource.patch(...args); + } +} module.exports = EmailTemplatesManager; diff --git a/src/management/GrantsManager.js b/src/management/GrantsManager.js new file mode 100644 index 000000000..dc2e6fbfe --- /dev/null +++ b/src/management/GrantsManager.js @@ -0,0 +1,84 @@ +const BaseManager = require('./BaseManager'); + +/** + * Auth0 Grants Manager. + * + * See {@link https://auth0.com/docs/api/v2#!/Grants Grants} + */ +class GrantsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Grants Auth0 Grants endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/grants/:id'); + } + + /** + * Get all Auth0 Grants. + * + * @example + * var params = { + * per_page: 10, + * page: 0, + * include_totals: true, + * user_id: 'USER_ID', + * client_id: 'CLIENT_ID', + * audience: 'AUDIENCE' + * }; + * + * management.getGrants(params, function (err, grants) { + * console.log(grants.length); + * }); + * @param {object} params Grants parameters. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {string} params.user_id The user_id of the grants to retrieve. + * @param {string} params.client_id The client_id of the grants to retrieve. + * @param {string} params.audience The audience of the grants to retrieve. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); + } + + /** + * Delete an Auth0 grant. + * + * @example + * var params = { + * id: 'GRANT_ID', + * user_id: 'USER_ID' + * }; + * + * management.deleteGrant(params, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Grant deleted. + * }); + * @param {object} params Grant parameters. + * @param {string} params.id Grant ID. + * @param {string} params.user_id The user_id of the grants to delete. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } +} + +module.exports = GrantsManager; diff --git a/src/management/GuardianManager.js b/src/management/GuardianManager.js index c1f516ca1..f6c7099b8 100644 --- a/src/management/GuardianManager.js +++ b/src/management/GuardianManager.js @@ -1,277 +1,361 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - -/** - * @class * Abstracts interaction with the Guardian endpoint. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var GuardianManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); +class GuardianManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for retrieving Guardian enrollments. + * + * @type {external:RestClient} + */ + this.enrollments = this._getRestClient('/guardian/enrollments/:id'); + + /** + * Provides an abstraction layer for retrieving Guardian tickets. + * + * @type {external:RestClient} + */ + this.tickets = this._getRestClient('/guardian/enrollments/ticket'); + + /** + * Provides an abstraction layer for retrieving Guardian factors. + * + * @type {external:RestClient} + */ + this.factors = this._getRestClient('/guardian/factors/:name'); + + /** + * Provides an abstraction layer for configuring Factor settings + * + * @type {external:RestClient} + */ + this.factorSettings = this._getRestClient('/guardian/factors/:name/settings'); + + /** + * Provides an abstraction layer for retrieving Guardian factor templates. + * + * @type {external:RestClient} + */ + this.factorsTemplates = this._getRestClient('/guardian/factors/:name/templates'); + + /** + * Provides an abstraction layer for retrieving Guardian factor providers. + * + * @type {external:RestClient} + */ + this.factorsProviders = this._getRestClient('/guardian/factors/:name/providers/:provider'); + + /** + * Provides an abstraction layer for retrieving Guardian policies. + * + * @type {external:RestClient} + */ + this.policies = this._getRestClient('/guardian/policies'); + + /** + * Provides an abstraction layer for retrieving Guardian phone factor selected provider. + * + * @type {external:RestClient} + */ + this.factorsPhoneSelectedProvider = this._getRestClient( + '/guardian/factors/sms/selected-provider' + ); + + /** + * Provides an abstraction layer for retrieving Guardian phone factor message types. + * + * @type {external:RestClient} + */ + this.factorsPhoneMessageTypes = this._getRestClient('/guardian/factors/phone/message-types'); } - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Get a single Guardian enrollment. + * + * @example + * management.guardian.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) { + * console.log(enrollment); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianEnrollment(...args) { + return this.enrollments.get(...args); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Delete a Guardian enrollment. + * + * @example + * management.guardian.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollments) { + * console.log(enrollments); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteGuardianEnrollment(...args) { + return this.enrollments.delete(...args); } - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + /** + * Create a Guardian enrollment ticket. + * + * @example + * management.guardian.createEnrollmentTicket(function (err, ticket) { + * console.log(ticket); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createEnrollmentTicket(...args) { + return this.tickets.create(...args); + } /** - * Provides an abstraction layer for retrieving Guardian enrollments. + * Get a list of factors and statuses. * - * @type {external:RestClient} + * @example + * management.guardian.getFactors(function (err, factors) { + * console.log(factors.length); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var guardianEnrollmentsAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/guardian/enrollments/:id', - clientOptions, - options.tokenProvider - ); - this.enrollments = new RetryRestClient(guardianEnrollmentsAuth0RestClient, options.retry); + getFactors(...args) { + return this.factors.getAll(...args); + } /** - * Provides an abstraction layer for retrieving Guardian tickets. + * Get Guardian factor configuration * - * @type {external:RestClient} + * @example + * management.guardian.getFactorSettings({ name: 'webauthn-roaming' }, function (err, settings) { + * console.log(settings); + * }); + * @param {object} params Factor parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var guardianTicketsAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/guardian/enrollments/ticket', - clientOptions, - options.tokenProvider - ); - this.tickets = new RetryRestClient(guardianTicketsAuth0RestClient, options.retry); + getFactorSettings(...args) { + return this.factorSettings.get(...args); + } /** - * Provides an abstraction layer for retrieving Guardian factors. + * Update Guardian factor configuration * - * @type {external:RestClient} + * @example + * management.guardian.updateFactorSettings( + * { name: 'webauthn-roaming' }, + * { userVerification: 'discouraged', overrideRelyingParty: false }, + * function (err, settings) { + * console.log(settings); + * }); + * @param {object} params Factor parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var guardianFactorsAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/guardian/factors/:name', - clientOptions, - options.tokenProvider - ); - this.factors = new RetryRestClient(guardianFactorsAuth0RestClient, options.retry); + updateFactorSettings(...args) { + return this.factorSettings.update(...args); + } /** - * Provides an abstraction layer for retrieving Guardian factors. + * Get Guardian factor provider configuration * - * @type {external:RestClient} + * @example + * management.guardian.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) { + * console.log(provider); + * }); + * @param {object} params Factor provider parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var guardianFactorsTemplatesAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/guardian/factors/:name/templates', - clientOptions, - options.tokenProvider - ); - this.factorsTemplates = new RetryRestClient( - guardianFactorsTemplatesAuth0RestClient, - options.retry - ); + getFactorProvider(...args) { + return this.factorsProviders.get(...args); + } /** - * Provides an abstraction layer for retrieving Guardian factor providers. + * Update Guardian's factor provider * - * @type {external:RestClient} + * @example + * management.guardian.updateFactorProvider({ name: 'sms', provider: 'twilio' }, { + * messaging_service_sid: 'XXXXXXXXXXXXXX', + * auth_token: 'XXXXXXXXXXXXXX', + * sid: 'XXXXXXXXXXXXXX' + * }, function (err, provider) { + * console.log(provider); + * }); + * @param {object} params Factor provider parameters. + * @param {object} data Updated Factor provider data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var guardianFactorsProvidersAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/guardian/factors/:name/providers/:provider', - clientOptions, - options.tokenProvider - ); - this.factorsProviders = new RetryRestClient( - guardianFactorsProvidersAuth0RestClient, - options.retry - ); -}; + updateFactorProvider(...args) { + return this.factorsProviders.update(...args); + } -/** - * Get a single Guardian enrollment. - * - * @method getGuardianEnrollment - * @memberOf module:management.GuardianManager.prototype - * - * @example - * management.guardian.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) { - * console.log(enrollment); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'getGuardianEnrollment', 'enrollments.get'); + /** + * Get Guardian enrollment and verification factor templates + * + * @example + * management.guardian.getFactorTemplates({ name: 'sms' }, function (err, templates) { + * console.log(templates); + * }); + * @param {object} params Factor parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getFactorTemplates(...args) { + return this.factorsTemplates.get(...args); + } -/** - * Delete a Guardian enrollment. - * - * @method deleteGuardianEnrollment - * @memberOf module:management.GuardianManager.prototype - * - * @example - * management.guardian.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollments) { - * console.log(enrollments); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'deleteGuardianEnrollment', 'enrollments.delete'); + /** + * Update Guardian enrollment and verification factor templates + * + * @example + * management.guardian.updateFactorProvider({ name: 'sms' }, { + * enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.", + * verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}" + * }, function (err, templates) { + * console.log(templates); + * }); + * @param {object} params Factor parameters. + * @param {object} data Updated factor templates data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateFactorTemplates(...args) { + return this.factorsTemplates.update(...args); + } -/** - * Create a Guardian enrollment ticket. - * - * @method createEnrollmentTicket - * @memberOf module:management.GuardianManager.prototype - * - * @example - * management.guardian.createEnrollmentTicket(function (err, ticket) { - * console.log(ticket); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'createEnrollmentTicket', 'tickets.create'); + /** + * Update Guardian Factor + * + * @example + * management.guardian.updateFactor({ name: 'sms' }, { + * enabled: true + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Factor parameters. + * @param {object} data Updated factor data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateFactor(...args) { + return this.factors.update(...args); + } -/** - * Get a list of factors and statuses. - * - * @method getFactors - * @memberOf module:management.GuardianManager.prototype - * - * management.guardian.getFactors(function (err, factors) { - * console.log(factors.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'getFactors', 'factors.getAll'); + /** + * Get enabled Guardian policies + * + * @example + * management.guardian.getPolicies(function (err, policies) { + * console.log(policies); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPolicies(...args) { + return this.policies.get(...args); + } -/** - * Get Guardian factor provider configuration - * - * @method getFactorProvider - * @memberOf module:management.GuardianManager.prototype - * - * management.guardian.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) { - * console.log(provider); - * }); - * - * @param {Object} params Factor provider parameters. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'getFactorProvider', 'factorsProviders.get'); + /** + * Update enabled Guardian policies + * + * @example + * management.guardian.updatePolicies({}, [ + * 'all-applications' + * ], function (err, policies) { + * console.log(policies); + * }); + * @param {object} params Parameters. + * @param {string[]} data Policies to enable. Empty array disables all policies. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updatePolicies(...args) { + return this.policies.update(...args); + } -/** - * Update Guardian's factor provider - * - * @method updateFactorProvider - * @memberOf module:management.GuardianManager.prototype - * - * management.guardian.updateFactorProvider({ name: 'sms', provider: 'twilio' }, { - * messaging_service_sid: 'XXXXXXXXXXXXXX', - * auth_token: 'XXXXXXXXXXXXXX', - * sid: 'XXXXXXXXXXXXXX' - * }, function(err, provider) { - * console.log(provider); - * }); - * - * @param {Object} params Factor provider parameters. - * @param {Object} data Updated Factor provider data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'updateFactorProvider', 'factorsProviders.update'); + /** + * Get the Guardian phone factor's selected provider + * + * @example + * management.guardian.getPhoneFactorSelectedProvider(function (err, selectedProvider) { + * console.log(selectedProvider); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPhoneFactorSelectedProvider(...args) { + return this.factorsPhoneSelectedProvider.get(...args); + } -/** - * Get Guardian enrollment and verification factor templates - * - * @method getFactorTemplates - * @memberOf module:management.GuardianManager.prototype - * - * management.guardian.getFactorTemplates({ name: 'sms' }, function (err, templates) { - * console.log(templates); - * }); - * - * @param {Object} params Factor parameters. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'getFactorTemplates', 'factorsTemplates.get'); + /** + * Update the Guardian phone factor's selected provider + * + * @example + * management.guardian.updatePhoneFactorSelectedProvider({}, { + * provider: 'twilio' + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Parameters. + * @param {object} data Updated selected provider data. + * @param {string} data.provider Name of the selected provider + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updatePhoneFactorSelectedProvider(...args) { + return this.factorsPhoneSelectedProvider.update(...args); + } -/** - * Update Guardian enrollment and verification factor templates - * - * @method updateFactorTemplates - * @memberOf module:management.GuardianManager.prototype - * - * management.guardian.updateFactorProvider({ name: 'sms' }, { - * enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.", - * verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}" - * }, function(err, templates) { - * console.log(templates); - * }); - * - * @param {Object} params Factor parameters. - * @param {Object} data Updated factor templates data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'updateFactorTemplates', 'factorsTemplates.update'); + /** + * Get the Guardian phone factor's message types + * + * @example + * management.guardian.getPhoneFactorMessageTypes(function (err, messageTypes) { + * console.log(messageTypes); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPhoneFactorMessageTypes(...args) { + return this.factorsPhoneMessageTypes.get(...args); + } -/** - * Update Guardian Factor - * - * @method updateFactor - * @memberOf module:management.GuardianManager.prototype - * - * management.guardian.updateFactor({ name: 'sms' }, { - * enabled: true - * }, function(err, factor) { - * console.log(factor); - * }); - * - * @param {Object} params Factor parameters. - * @param {Object} data Updated factor data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(GuardianManager, 'updateFactor', 'factors.update'); + /** + * Update the Guardian phone factor's message types + * + * @example + * management.guardian.updatePhoneFactorMessageTypes({}, { + * message_types: ['sms', 'voice'] + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Parameters. + * @param {object} data Updated selected provider data. + * @param {string[]} data.message_types Message types (only `"sms"` and `"voice"` are supported). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updatePhoneFactorMessageTypes(...args) { + return this.factorsPhoneMessageTypes.update(...args); + } +} module.exports = GuardianManager; diff --git a/src/management/HooksManager.js b/src/management/HooksManager.js new file mode 100644 index 000000000..769e91491 --- /dev/null +++ b/src/management/HooksManager.js @@ -0,0 +1,295 @@ +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); + +/** + * The hooks manager class provides a simple abstraction for performing CRUD operations + * on Auth0 HooksManagers. + */ +class HooksManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/v2#!/HooksManagers Auth0 HooksManagers}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/hooks/:id'); + + this.secrets = this._getRestClient('/hooks/:id/secrets'); + } + + /** + * Create a new hook. + * + * @example + * management.hooks.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Hook created. + * }); + * @param {object} data Hook data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); + } + + /** + * Get all hooks. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.hooks.getAll(params, function (err, hooks) { + * console.log(hooks.length); + * }); + * @param {object} [params] Hooks parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); + } + + /** + * Get an Auth0 hook. + * + * @example + * management.hooks.get({ id: HOOK_ID }, function (err, hook) { + * if (err) { + * // Handle error. + * } + * + * console.log(hook); + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + get(...args) { + return this.resource.get(...args); + } + + /** + * Update an existing hook. + * + * @example + * var data = { name: 'New name' }; + * var params = { id: HOOK_ID }; + * + * // Using auth0 instance. + * management.updateHook(params, data, function (err, hook) { + * if (err) { + * // Handle error. + * } + * + * console.log(hook.name); // 'New name' + * }); + * + * // Using the hooks manager directly. + * management.hooks.update(params, data, function (err, hook) { + * if (err) { + * // Handle error. + * } + * + * console.log(hook.name); // 'New name' + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Updated hook data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + update(...args) { + return this.resource.patch(...args); + } + + /** + * Delete an existing hook. + * + * @example + * management.hooks.delete({ id: HOOK_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Hook deleted. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } + + /** + * Get Hook secrets + * + * @example + * This method takes a first argument as the hookId and returns the secrets for the hook. The secret values will be hidden. + * + * + * var params = {id : 'HOOK_ID'} + * + * management.hooks.getSecrets( {id : 'HOOK_ID'}, function (err, secrets) { + * console.log(secrets); + * }); + * @param {object} params Hook parameters. + * @param {string} params.id ID of the Hook. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getSecrets(params, callback) { + return this.secrets.getAll(params, callback); + } + + /** + * Add secrets in a hook + * + * @example + * var params = { id :'HOOK_ID'}; + * var data = { "DB_USER" : "jdoe", "DB_PASS": "password123!"}; + * + * management.hooks.addSecrets(params, data, function (err, secrets) { + * if (err) { + * // Handle error. + * } + * + * // secrets added. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id ID of the Hook. + * @param {object} data object containing secrets as key/value pairs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + addSecrets(params, data, cb) { + params = params || {}; + data = data || {}; + + // Require an ID. + if (!params.id) { + throw new ArgumentError('The id passed in params cannot be null or undefined'); + } + + if (typeof params.id !== 'string') { + throw new ArgumentError('The hook Id has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.secrets.create(params, data, cb); + } + + return this.secrets.create(params, data); + } + + /** + * Update secrets in a hook + * + * @example + * var params = { id :'HOOK_ID'}; + * var data = { "DB_USER" : "jdoe", "DB_PASS": "password123!"}; + * + * management.hooks.updateSecrets(params, data, function (err, secrets) { + * if (err) { + * // Handle error. + * } + * + * // secrets updated. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id ID of the Hook. + * @param {object} data object containing secrets as key/value pairs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + updateSecrets(params, data, cb) { + params = params || {}; + data = data || {}; + + // Require an ID. + if (!params.id) { + throw new ArgumentError('The id passed in params cannot be null or undefined'); + } + + if (typeof params.id !== 'string') { + throw new ArgumentError('The hook Id has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.secrets.patch(params, data, cb); + } + + return this.secrets.patch(params, data); + } + + /** + * Remove secrets from a hook + * + * @example + * var params = { id :'HOOK_ID'}; + * var data =["DB_PASS"]; + * + * management.hooks.removeSecrets(params, data, function (err, hook) { + * if (err) { + * // Handle error. + * } + * + * // secrets added. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id ID of the Hook. + * @param {object} data Array of secret names + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + removeSecrets(params, data, cb) { + params = params || {}; + data = data || {}; + + // Require an ID. + if (!params.id) { + throw new ArgumentError('The id passed in params cannot be null or undefined'); + } + + if (typeof params.id !== 'string') { + throw new ArgumentError('The hook Id has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.secrets.delete(params, data, cb); + } + + return this.secrets.delete(params, data); + } +} + +module.exports = HooksManager; diff --git a/src/management/JobsManager.js b/src/management/JobsManager.js index 4d87b087f..ef156adc8 100644 --- a/src/management/JobsManager.js +++ b/src/management/JobsManager.js @@ -1,233 +1,324 @@ -var request = require('request'); -var extend = require('util')._extend; -var Promise = require('bluebird'); -var fs = require('fs'); +const axios = require('axios'); +const FormData = require('form-data'); +const fs = require('fs'); -var ArgumentError = require('rest-facade').ArgumentError; -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - -/** - * @class * Abstract the creation as well as the retrieval of async jobs. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var JobsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide client options'); - } +class JobsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); - } + this.options = options; - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); - } + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Jobs Jobs endpoint}. + * + * @type {external:RestClient} + */ + this.jobs = this._getRestClient('/jobs/:id'); - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Jobs/:id/errors Errors endpoint}. + * + * @type {external:RestClient} + */ + this.jobErrors = this._getRestClient('/jobs/:id/errors'); - this.options = options; + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Jobs/post_users_exports Create job to export users endpoint} + * + * @type {external:RestClient} + */ + this.usersExports = this._getRestClient('/jobs/users-exports'); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Jobs Jobs endpoint}. + * Get a job by its ID. + * + * @example + * var params = { + * id: '{JOB_ID}' + * }; + * + * management.jobs.get(params, function (err, job) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * // Retrieved job. + * console.log(job); + * }); + * @param {object} params Job parameters. + * @param {string} params.id Job ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/jobs/:id', - clientOptions, - options.tokenProvider - ); - this.jobs = new RetryRestClient(auth0RestClient, options.retry); -}; + get(params, cb) { + if (!params.id || typeof params.id !== 'string') { + throw new ArgumentError('The id parameter must be a valid job id'); + } -/** - * Get a job by its ID. - * - * @method get - * @memberOf module:management.JobsManager.prototype - * - * @example - * var params = { - * id: '{JOB_ID}' - * }; - * - * management.jobs.get(params, function (err, job) { - * if (err) { - * // Handle error. - * } - * - * // Retrieved job. - * console.log(job); - * }); - * - * @param {Object} params Job parameters. - * @param {String} params.id Job ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -JobsManager.prototype.get = function(params, cb) { - if (!params.id || typeof params.id !== 'string') { - throw new ArgumentError('The id parameter must be a valid job id'); - } + if (cb && cb instanceof Function) { + return this.jobs.get(params, cb); + } - if (cb && cb instanceof Function) { - return this.jobs.get(params, cb); + // Return a promise. + return this.jobs.get(params); } - // Return a promise. - return this.jobs.get(params); -}; + _importUsers(data, cb) { + const { options } = this; + const url = `${options.baseUrl}/jobs/users-imports`; + const userData = data.users_json + ? Buffer.from(data.users_json) + : fs.createReadStream(data.users); + const userFilename = data.users_json ? 'users.json' : data.users; -/** - * Given a path to a file and a connection id, create a new job that imports the - * users contained in the file or JSON string and associate them with the given - * connection. - * - * @method importUsers - * @memberOf module:management.JobsManager.prototype - * - * @example - * var params = { - * connection_id: '{CONNECTION_ID}', - * users: '{PATH_TO_USERS_FILE}', - * upsert: true, //optional - * send_completion_email: false //optional - * }; - * - * management.jobs.get(params, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data Users import data. - * @param {String} data.connectionId Connection for the users insertion. - * @param {String} data.users Path to the users data file. - * @param {String} data.users_json JSON data for the users. - * @param {String} data.upsert OPTIONAL: set to true to upsert users, defaults to false - * @param {String} data.send_completion_email OPTIONAL: defaults to true - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -JobsManager.prototype.importUsers = function(data, cb) { - var options = this.options; - var headers = extend({}, options.headers); - - headers['Content-Type'] = 'multipart/form-data'; - - var url = options.baseUrl + '/jobs/users-imports'; - var method = 'POST'; - var upsert = data.upsert === true ? 'true' : 'false'; - var send_completion_email = data.send_completion_email === false ? 'false' : 'true'; - - var promise = options.tokenProvider.getAccessToken().then(function(access_token) { - return new Promise(function(resolve, reject) { - request( - { - url: url, - method: method, - headers: extend({ Authorization: `Bearer ${access_token}` }, headers), - formData: { - users: { - value: data.users_json - ? Buffer.from(data.users_json) - : fs.createReadStream(data.users), - options: { - filename: data.users_json ? 'users.json' : data.users - } - }, - connection_id: data.connection_id, - upsert: upsert, - send_completion_email: send_completion_email - } - }, - function(err, res) { - if (err) { - reject(err); - return; - } - // `superagent` uses the error parameter in callback on http errors. - // the following code is intended to keep that behaviour (https://github.com/visionmedia/superagent/blob/master/lib/node/response.js#L170) - var type = (res.statusCode / 100) | 0; - var isErrorResponse = 4 === type || 5 === type; - if (isErrorResponse) { - var error = new Error('cannot ' + method + ' ' + url + ' (' + res.statusCode + ')'); - error.status = res.statusCode; - error.method = method; - error.text = res.text; - reject(error); - } - resolve(res); + const form = new FormData(); + form.append('users', userData, userFilename); + form.append('connection_id', data.connection_id); + form.append('upsert', data.upsert === true ? 'true' : 'false'); + form.append('send_completion_email', data.send_completion_email === false ? 'false' : 'true'); + + const headers = { ...options.headers, ...form.getHeaders() }; + headers['Content-Type'] = 'multipart/form-data'; + + const promise = options.tokenProvider.getAccessToken().then(async (access_token) => { + try { + return await axios.post(url, form, { + headers: { ...headers, Authorization: `Bearer ${access_token}` }, + }); + } catch (err) { + if (!err.response) { + throw err; } - ); + + const res = err.response; + // `superagent` uses the error parameter in callback on http errors. + // the following code is intended to keep that behaviour (https://github.com/visionmedia/superagent/blob/master/lib/node/response.js#L170) + const error = new Error(`${'cannot POST' + ' '}${url} (${res.status})`); + error.status = res.status; + error.method = 'POST'; + error.text = res.data.message || res.statusText || error.message; + throw error; + } }); - }); - // Don't return a promise if a callback was given. - if (cb && cb instanceof Function) { - promise.then(cb.bind(null, null)).catch(cb); + // Don't return a promise if a callback was given. + if (cb && cb instanceof Function) { + promise.then(cb.bind(null, null)).catch(cb); + + return; + } - return; + return promise; } - return promise; -}; + /** + * Given a path to a file and a connection id, create a new job that imports the + * users contained in the file or JSON string and associate them with the given + * connection. + * + * @deprecated since version 2.26. It will be deleted in version 3.0. + * @example + * var params = { + * connection_id: '{CONNECTION_ID}', + * users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}' + * }; + * + * management.jobs.importUsers(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data Users import data. + * @param {string} data.connection_id connection_id of the connection to which users will be imported. + * @param {string} [data.users] Path to the users data file. Either users or users_json is mandatory. + * @param {string} [data.users_json] JSON data for the users. + * @param {boolean} [data.upsert] Whether to update users if they already exist (true) or to ignore them (false). + * @param {boolean} [data.send_completion_email] Whether to send a completion email to all tenant owners when the job is finished (true) or not (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + importUsers(data, cb) { + console.warn( + '"importUsers" has been deprecated as it was inconsistent with the API. Please, use "importUsersJob" which returns the response data directly.' + ); + return this._importUsers(data, cb); + } -/** - * Send a verification email to a user. - * - * @method verifyEmail - * @memberOf module:management.JobsManager.prototype - * - * @example - * var params = { - * user_id: '{USER_ID}' - * }; - * - * management.jobs.verifyEmail(function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data User data object. - * @param {String} data.user_id ID of the user to be verified. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -JobsManager.prototype.verifyEmail = function(data, cb) { - if (!data.user_id || typeof data.user_id !== 'string') { - throw new ArgumentError('Must specify a user ID'); + /** + * Given a path to a file and a connection id, create a new job that imports the + * users contained in the file or JSON string and associate them with the given + * connection. + * + * @example + * var params = { + * connection_id: '{CONNECTION_ID}', + * users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}' + * }; + * + * management.jobs.importUsers(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data Users import data. + * @param {string} data.connection_id connection_id of the connection to which users will be imported. + * @param {string} [data.users] Path to the users data file. Either users or users_json is mandatory. + * @param {string} [data.users_json] JSON data for the users. + * @param {boolean} [data.upsert] Whether to update users if they already exist (true) or to ignore them (false). + * @param {boolean} [data.send_completion_email] Whether to send a completion email to all tenant owners when the job is finished (true) or not (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + importUsersJob(data, cb) { + const promise = this._importUsers(data).then((response) => response.data); + + // Don't return a promise if a callback was given. + if (cb && cb instanceof Function) { + promise.then(cb.bind(null, null)).catch(cb); + + return; + } + + return promise; + } + + /** + * Export all users to a file using a long running job. + * + * @example + * var data = { + * connection_id: 'con_0000000000000001', + * format: 'csv', + * limit: 5, + * fields: [ + * { + * "name": "user_id" + * }, + * { + * "name": "name" + * }, + * { + * "name": "email" + * }, + * { + * "name": "identities[0].connection", + * "export_as": "provider" + * }, + * { + * "name": "user_metadata.some_field" + * } + * ] + * } + * + * management.jobs.exportUsers(data, function (err, results) { + * if (err) { + * // Handle error. + * } + * + * // Retrieved job. + * console.log(results); + * }); + * @param {object} data Users export data. + * @param {string} [data.connection_id] The connection id of the connection from which users will be exported + * @param {string} [data.format] The format of the file. Valid values are: "json" and "csv". + * @param {number} [data.limit] Limit the number of records. + * @param {object[]} [data.fields] A list of fields to be included in the CSV. If omitted, a set of predefined fields will be exported. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + exportUsers(data, cb) { + if (cb && cb instanceof Function) { + return this.usersExports.create(data, cb); + } + + return this.usersExports.create(data); } - if (cb && cb instanceof Function) { - return this.jobs.create({ id: 'verification-email' }, data, cb); + /** + * Given a job ID, retrieve the failed/errored items + * + * @example + * var params = { + * id: '{JOB_ID}' + * }; + * + * management.jobs.errors(params, function (err, job) { + * if (err) { + * // Handle error. + * } + * + * // Retrieved job. + * console.log(job); + * }); + * @param {object} params Job parameters. + * @param {string} params.id Job ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + errors(params, cb) { + if (!params.id || typeof params.id !== 'string') { + throw new ArgumentError('The id parameter must be a valid job id'); + } + + if (cb && cb instanceof Function) { + return this.jobErrors.get(params, cb); + } + + // Return a promise. + return this.jobErrors.get(params); } - // Return a promise. - return this.jobs.create({ id: 'verification-email' }, data); -}; + /** + * Send a verification email to a user. + * + * @example + * var params = { + * user_id: '{USER_ID}' + * }; + * + * management.jobs.verifyEmail(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data User data object. + * @param {string} data.user_id ID of the user to be verified. + * @param {string} [data.organization_id] Organization ID + * @param {string} [data.client_id] client_id of the client (application). If no value provided, the global Client ID will be used. + * @param {object} [data.identity] Used to verify secondary, federated, and passwordless-email identities. + * @param {string} data.identity.user_id user_id of the identity. + * @param {string} data.identity.provider provider of the identity. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + verifyEmail(data, cb) { + if (!data.user_id || typeof data.user_id !== 'string') { + throw new ArgumentError('Must specify a user ID'); + } + + if (cb && cb instanceof Function) { + return this.jobs.create({ id: 'verification-email' }, data, cb); + } + + // Return a promise. + return this.jobs.create({ id: 'verification-email' }, data); + } +} module.exports = JobsManager; diff --git a/src/management/LogStreamsManager.js b/src/management/LogStreamsManager.js new file mode 100644 index 000000000..59286554c --- /dev/null +++ b/src/management/LogStreamsManager.js @@ -0,0 +1,136 @@ +const BaseManager = require('./BaseManager'); + +/** + * The logStreams class provides a simple abstraction for performing CRUD operations + * on Auth0 Log Streams. + */ +class LogStreamsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/management/v2#!/Log_Streams Auth0 + * Log Streams}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/log-streams/:id '); + } + + /** + * Get all Log Streams. + * + * @example + * + * management.logStreams.getAll(function (err, logStreams) { + * console.log(logStreams.length); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); + } + + /** + * Get an Auth0 Log Streams. + * + * @example + * management.logStreams.get({ id: LOG_STREAM_ID }, function (err, logStream) { + * if (err) { + * // Handle error. + * } + * + * console.log(logStream); + * }); + * @param {object} params Log Stream parameters. + * @param {string} params.id Log Stream ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + get(...args) { + return this.resource.get(...args); + } + + /** + * Create an Auth0 Log Stream. + * + * @example + * management.logStreams.create(data, function (err, log) { + * if (err) { + * // Handle error. + * } + * + * console.log(log); + * }); + * @param {object} data Log Stream data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); + } + + /** + * Update an Auth0 Log Streams. + * + * @example + * var data = { name: 'New name' }; + * var params = { id: LOG_STREAM_ID }; + * + * // Using auth0 instance. + * management.updateLogStream(params, data, function (err, logStream) { + * if (err) { + * // Handle error. + * } + * + * console.log(logStream.name); // 'New name' + * }); + * + * // Using the logStreams manager directly. + * management.logStreams.update(params, data, function (err, logStream) { + * if (err) { + * // Handle error. + * } + * + * console.log(logStream.name); + * }); + * @param {object} params Log Stream parameters. + * @param {string} params.id Log Stream ID. + * @param {object} data Updated Log Stream data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + update(...args) { + return this.resource.patch(...args); + } + + /** + * Delete an Auth0 Log Streams. + * + * @example + * management.logStreams.delete({ id: LOG_STREAM_ID }, function (err, log) { + * if (err) { + * // Handle error. + * } + * + * console.log(log); + * }); + * @param {object} params Log Stream parameters. + * @param {string} params.id Log Stream ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } +} + +module.exports = LogStreamsManager; diff --git a/src/management/LogsManager.js b/src/management/LogsManager.js index debf268bb..b6b4e728f 100644 --- a/src/management/LogsManager.js +++ b/src/management/LogsManager.js @@ -1,114 +1,82 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * @class LogsManager * Represents the relationship between Auth0 and an Identity provider. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var LogsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide client options'); - } - - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); - } +class LogsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/v2#!/LogsManagers Auth0 + * Logs}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/logs/:id'); } /** - * Options object for the Rest Client instance. + * Get all logs. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings and the search query. If pagination options are + * not present, the first page of a limited number of results will be returned. + * * - * @type {Object} + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 2 + * }; + * + * management.logs.getAll(params, function (err, logs) { + * console.log(logs.length); + * }); + * @param {object} [params] Logs params. + * @param {string} [params.q] Search Criteria using Query String Syntax + * @param {number} [params.page] Page number. Zero based + * @param {number} [params.per_page] The amount of entries per page + * @param {string} [params.sort] The field to use for sorting. + * @param {string} [params.fields] A comma separated list of fields to include or exclude + * @param {boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise. + * @param {boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false + * @param {string} [params.from] For checkpoint pagination, log event Id from which to start selection from. + * @param {number} [params.take] When using the `from` parameter, the number of entries to retrieve. Default 50, max 100. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - headers: options.headers, - query: { repeatParams: false } - }; + getAll(...args) { + return this.resource.getAll(...args); + } /** - * Provides an abstraction layer for performing CRUD operations on - * {@link https://auth0.com/docs/api/v2#!/LogsManagers Auth0 - * Logs}. + * Get an Auth0 log. * - * @type {external:RestClient} + * @example + * management.logs.get({ id: EVENT_ID }, function (err, log) { + * if (err) { + * // Handle error. + * } + * + * console.log(log); + * }); + * @param {object} params Log parameters. + * @param {string} params.id Log ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/logs/:id ', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Get all logs. - * - * @method getAll - * @memberOf module:management.LogsManager.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings and the search query. If pagination options are - * not present, the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 2 - * }; - * - * management.logs.getAll(params, function (err, logs) { - * console.log(logs.length); - * }); - * - * @param {Object} [params] Logs params. - * @param {String} [params.q] Search Criteria using Query String Syntax - * @param {Number} [params.page] Page number. Zero based - * @param {Number} [params.per_page] The amount of entries per page - * @param {String} [params.sort] The field to use for sorting. - * @param {String} [params.fields] A comma separated list of fields to include or exclude - * @param {Boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise. - * @param {Boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(LogsManager, 'getAll', 'resource.getAll'); - -/** - * Get an Auth0 log. - * - * @method get - * @memberOf module:management.LogsManager.prototype - * - * @example - * management.logs.get({ id: EVENT_ID }, function (err, log) { - * if (err) { - * // Handle error. - * } - * - * console.log(log); - * }); - * - * @param {Object} params Log parameters. - * @param {String} params.id Log ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(LogsManager, 'get', 'resource.get'); + get(...args) { + return this.resource.get(...args); + } +} module.exports = LogsManager; diff --git a/src/management/ManagementTokenProvider.js b/src/management/ManagementTokenProvider.js index 59996fb2b..dbd207872 100644 --- a/src/management/ManagementTokenProvider.js +++ b/src/management/ManagementTokenProvider.js @@ -1,138 +1,135 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var assign = Object.assign || require('object.assign'); -var AuthenticationClient = require('../auth'); -var memoizer = require('lru-memoizer'); -var Promise = require('bluebird'); - -var DEFAULT_OPTIONS = { enableCache: true }; +const { ArgumentError } = require('rest-facade'); +const AuthenticationClient = require('../auth'); +const memoizer = require('lru-memoizer'); +const util = require('util'); /** - * @class ManagementTokenProvider * Auth0 Management API Token Provider. - * @constructor - * @memberOf module:management - * - * @param {Object} options Options for the ManagementTokenProvider. - * @param {String} options.domain ManagementClient server domain. - * @param {String} options.clientId Non Interactive Client Id. - * @param {String} options.clientSecret Non Interactive Client Secret. - * @param {String} options.scope Non Interactive Client Scope. - * @param {String} options.audience Audience of the Management API. - * @param {Boolean} [options.enableCache=true] Enabled or Disable Cache - * @param {Number} [options.cacheTTLInSeconds] By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden. */ -var ManagementTokenProvider = function(options) { - if (!options || typeof options !== 'object') { - throw new ArgumentError('Options must be an object'); - } +class ManagementTokenProvider { + /** + * @param {object} options Options for the ManagementTokenProvider. + * @param {string} options.domain ManagementClient server domain. + * @param {string} options.clientId Non Interactive Client Id. + * @param {string} options.clientSecret Non Interactive Client Secret. + * @param {string} options.scope Non Interactive Client Scope. + * @param {string} options.audience Audience of the Management API. + * @param {boolean} [options.enableCache=true] Enabled or Disable Cache + * @param {number} [options.cacheTTLInSeconds] By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden. + * @param {object} [options.headers] Additional headers that will be added to the outgoing requests. + */ + constructor(options) { + if (!options || typeof options !== 'object') { + throw new ArgumentError('Options must be an object'); + } - var params = assign({}, DEFAULT_OPTIONS, options); + const params = { enableCache: true, ...options }; - if (!params.domain || params.domain.length === 0) { - throw new ArgumentError('Must provide a domain'); - } + if (!params.domain || params.domain.length === 0) { + throw new ArgumentError('Must provide a domain'); + } - if (!params.clientId || params.clientId.length === 0) { - throw new ArgumentError('Must provide a clientId'); - } + if (!params.clientId || params.clientId.length === 0) { + throw new ArgumentError('Must provide a clientId'); + } - if (!params.clientSecret || params.clientSecret.length === 0) { - throw new ArgumentError('Must provide a clientSecret'); - } + if (!params.clientSecret || params.clientSecret.length === 0) { + throw new ArgumentError('Must provide a clientSecret'); + } - if (!params.audience || params.audience.length === 0) { - throw new ArgumentError('Must provide a audience'); - } + if (!params.audience || params.audience.length === 0) { + throw new ArgumentError('Must provide a audience'); + } - if (typeof params.enableCache !== 'boolean') { - throw new ArgumentError('enableCache must be a boolean'); - } + if (typeof params.enableCache !== 'boolean') { + throw new ArgumentError('enableCache must be a boolean'); + } - if (params.enableCache && params.cacheTTLInSeconds) { - if (typeof params.cacheTTLInSeconds !== 'number') { - throw new ArgumentError('cacheTTLInSeconds must be a number'); + if (params.enableCache && params.cacheTTLInSeconds) { + if (typeof params.cacheTTLInSeconds !== 'number') { + throw new ArgumentError('cacheTTLInSeconds must be a number'); + } + + if (params.cacheTTLInSeconds <= 0) { + throw new ArgumentError('cacheTTLInSeconds must be a greater than 0'); + } } - if (params.cacheTTLInSeconds <= 0) { - throw new ArgumentError('cacheTTLInSeconds must be a greater than 0'); + if (params.scope && typeof params.scope !== 'string') { + throw new ArgumentError('scope must be a string'); } - } - if (params.scope && typeof params.scope !== 'string') { - throw new ArgumentError('scope must be a string'); + this.options = params; + const authenticationClientOptions = { + domain: this.options.domain, + clientId: this.options.clientId, + clientSecret: this.options.clientSecret, + telemetry: this.options.telemetry, + clientInfo: this.options.clientInfo, + headers: this.options.headers, + }; + this.authenticationClient = new AuthenticationClient(authenticationClientOptions); + + const self = this; + this.getCachedAccessToken = util.promisify( + memoizer({ + load(options, callback) { + self + .clientCredentialsGrant(options.domain, options.scope, options.audience) + .then((data) => { + callback(null, data); + }) + .catch((err) => { + callback(err); + }); + }, + hash(options) { + return `${options.domain}-${options.clientId}-${options.scope}`; + }, + itemMaxAge(options, data) { + if (options.cacheTTLInSeconds) { + return options.cacheTTLInSeconds * 1000; + } + + // if the expires_in is lower or equal to than 10 seconds, do not subtract 10 additional seconds. + if (data.expires_in && data.expires_in <= 10 /* seconds */) { + return data.expires_in * 1000; + } else if (data.expires_in) { + // Subtract 10 seconds from expires_in to fetch a new one, before it expires. + return data.expires_in * 1000 - 10000 /* milliseconds */; + } + return 60 * 60 * 1000; //1h + }, + max: 100, + }) + ); } - this.options = params; - var authenticationClientOptions = { - domain: this.options.domain, - clientId: this.options.clientId, - clientSecret: this.options.clientSecret, - telemetry: this.options.telemetry - }; - this.authenticationClient = new AuthenticationClient(authenticationClientOptions); -}; - -/** - * Returns the access_token. - * - * @method getAccessToken - * @memberOf module:management.ManagementTokenProvider.prototype - * - * @return {Promise} Promise returning an access_token. - */ -ManagementTokenProvider.prototype.getAccessToken = function() { - if (this.options.enableCache) { - return this.getCachedAccessToken(this.options).then(function(data) { + /** + * Returns the access_token. + * + * @returns {Promise} Promise returning an access_token. + */ + async getAccessToken() { + if (this.options.enableCache) { + const data = await this.getCachedAccessToken(this.options); return data.access_token; - }); - } else { - return this.clientCredentialsGrant( - this.options.domain, - this.options.scope, - this.options.audience - ).then(function(data) { + } else { + const data = await this.clientCredentialsGrant( + this.options.domain, + this.options.scope, + this.options.audience + ); return data.access_token; - }); + } } -}; - -ManagementTokenProvider.prototype.getCachedAccessToken = Promise.promisify( - memoizer({ - load: function(options, callback) { - this.clientCredentialsGrant(options.domain, options.scope, options.audience) - .then(function(data) { - callback(null, data); - }) - .catch(function(err) { - callback(err); - }); - }, - hash: function(options) { - return options.domain + '-' + options.clientId + '-' + options.scope; - }, - itemMaxAge: function(options, data) { - if (options.cacheTTLInSeconds) { - return options.cacheTTLInSeconds * 1000; - } - // if the expires_in is lower than 10 seconds, do not subtract 10 additional seconds. - if (data.expires_in && data.expires_in < 10 /* seconds */) { - return data.expires_in * 1000; - } else if (data.expires_in) { - // Subtract 10 seconds from expires_in to fetch a new one, before it expires. - return data.expires_in * 1000 - 10000 /* milliseconds */; - } - return 60 * 60 * 1000; //1h - }, - max: 100 - }) -); - -ManagementTokenProvider.prototype.clientCredentialsGrant = function(domain, scope, audience) { - return this.authenticationClient.clientCredentialsGrant({ - audience: audience, - scope: scope - }); -}; + clientCredentialsGrant(domain, scope, audience) { + return this.authenticationClient.clientCredentialsGrant({ + audience, + scope, + }); + } +} module.exports = ManagementTokenProvider; diff --git a/src/management/MigrationsManager.js b/src/management/MigrationsManager.js new file mode 100644 index 000000000..59305d071 --- /dev/null +++ b/src/management/MigrationsManager.js @@ -0,0 +1,76 @@ +const BaseManager = require('./BaseManager'); + +/** + * Abstracts interaction with the migrations endpoint. + */ +class MigrationsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the migrations endpoint + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/migrations'); + } + + /** + * Update the tenant migrations. + * + * @example + * management.migrations.updateMigrations(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data The tenant migrations to be updated + * @param {object} data.flags The tenant migrations flags to be updated + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateMigrations(data, cb) { + if (cb && cb instanceof Function) { + return this.resource.patch({}, data, cb); + } + + // Return a promise. + return this.resource.patch({}, data); + } + + /** + * Get the tenant migrations. + * + * @example + * management.migrations.getMigrations(function (err, migrations) { + * if (err) { + * // Handle error. + * } + * + * console.log(migrations.flags); + * }); + * @param data + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getMigrations(data, cb) { + if (data instanceof Function && !cb) { + cb = data; + data = {}; + } + if (cb && cb instanceof Function) { + return this.resource.get(data, cb); + } + + // Return a promise. + return this.resource.get(data); + } +} + +module.exports = MigrationsManager; diff --git a/src/management/OrganizationsManager.js b/src/management/OrganizationsManager.js new file mode 100644 index 000000000..b60638b08 --- /dev/null +++ b/src/management/OrganizationsManager.js @@ -0,0 +1,721 @@ +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); + +/** + * The organizations class provides a simple abstraction for performing CRUD operations + * on Auth0 OrganizationsManager. + */ +class OrganizationsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/v2}. + * + * @type {external:RestClient} + */ + this.organizations = this._getRestClient('/organizations/:id'); + + this.connections = this._getRestClient('/organizations/:id/enabled_connections/:connection_id'); + + this.members = this._getRestClient('/organizations/:id/members/:user_id'); + + this.invitations = this._getRestClient('/organizations/:id/invitations/:invitation_id'); + + this.roles = this._getRestClient('/organizations/:id/members/:user_id/roles'); + + this.organizationsByName = this._getRestClient('/organizations/name/:name'); + } + + /** + * Create a new organization. + * + * @example + * management.organizations.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Organization created. + * }); + * @param {object} data Organization data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.organizations.create(...args); + } + + /** + * Get all organizations. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.organizations.getAll(params, function (err, organizations) { + * console.log(organizations.length); + * }); + * @param {object} [params] Organizations parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from. + * @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.organizations.getAll(...args); + } + + /** + * Get an Auth0 organization. + * + * @example + * management.organizations.getByID({ id: ORGANIZATION_ID }, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(organization); + * }); + * @param {object} params Organization parameters. + * @param {string} params.id Organization ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getByID(...args) { + return this.organizations.get(...args); + } + + /** + * Get an Auth0 organization. + * + * @example + * management.organizations.getByName({ name: ORGANIZATION_NAME}, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(organization); + * }); + * @param {object} params Organization parameters. + * @param {string} params.name Organization name. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getByName(...args) { + return this.organizationsByName.get(...args); + } + + /** + * Update an existing organization. + * + * @example + * var data = { display_name: 'New name' }; + * var params = { id: ORGANIZATION_ID }; + * + * management.organizations.update(params, data, function (err, organization) { + * if (err) { + * // Handle error. + * } + * + * console.log(organization.name); // 'New name' + * }); + * @param {object} params Organization parameters. + * @param {string} params.id Organization ID. + * @param {object} data Updated organization data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + update(...args) { + return this.organizations.patch(...args); + } + + /** + * Delete an existing organization. + * + * @example + * management.organizations.delete({ id: ORGANIZATION_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Organization deleted. + * }); + * @param {object} params Organization parameters. + * @param {string} params.id Organization ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.organizations.delete(...args); + } + + /** + *Organization Connections + */ + + /** + * Get Enabled Connections in a Organization + * + * @example + * This method takes an organization ID and returns the enabled connections in an Organization + * + * var params = {id : 'ORGANIZATION_ID'} + * + * management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID'}, function (err, enabled_connections) { + * console.log(enabled_connections); + * }); + * @param {object} params Organization parameters. + * @param {string} params.id Organization ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getEnabledConnections(params, callback) { + return this.connections.getAll(params, callback); + } + + /** + * Get Enabled Connection in a Organization + * + * @example + * This methods takes the organization ID and connection ID and returns the enabled connection + * + * var params = {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'} + * + * management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}, function (err, enabled_connection) { + * console.log(enabled_connection); + * }); + * @param {object} params Organization parameters. + * @param {string} params.id Organization ID. + * @param {string} params.connection_id Connection ID. + * @param {Function} [callback] Callback function. + * @returns {Promise|undefined} + */ + getEnabledConnection(params, callback) { + return this.connections.get(params, callback); + } + + /** + * Add an enabled connection for an organization + * + * @example + * var params = { id :'ORGANIZATION_ID'}; + * var data = { "connection_id" : "CONNECTION_ID", assign_membership_on_login: false }; + * + * management.organizations.addEnabledConnection(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {object} data enable connection data + * @param {string} data.connection_id connection ID to enable + * @param {boolean} data.assign_membership_on_login flag to allow assign membership on login + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + addEnabledConnection(params, data, cb) { + data = data || {}; + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.connections.create(params, data, cb); + } + + return this.connections.create(params, data); + } + + /** + * Remove an enabled connection from an organization + * + * @example + * var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' }; + * + * management.organizations.removeEnabledConnection(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {string} params.connection_id ID of the Connection. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + removeEnabledConnection(params, cb) { + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (!params.connection_id) { + throw new ArgumentError('The connection ID passed in params cannot be null or undefined'); + } + if (typeof params.connection_id !== 'string') { + throw new ArgumentError('The connection ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.connections.delete(params, {}, cb); + } + + return this.connections.delete(params, {}); + } + + /** + * Update an enabled connection from an organization + * + * @example + * var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' }; + * var data = { assign_membership_on_login: true }; + * + * management.organizations.updateEnabledConnection(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {string} params.connection_id ID of the Connection. + * @param {object} data Updated connection. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + updateEnabledConnection(params, data, cb) { + data = data || {}; + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (!params.connection_id) { + throw new ArgumentError('The connection ID passed in params cannot be null or undefined'); + } + if (typeof params.connection_id !== 'string') { + throw new ArgumentError('The connection ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.connections.patch(params, data, cb); + } + + return this.connections.patch(params, data); + } + + /** + *Organization Members + */ + + /** + * Get Members in a Organization + * + * @example + * This method takes an organization ID and returns the members in an Organization + * + * + * var params = {id : 'ORGANIZATION_ID'} + * + * management.organizations.getMembers( {id : 'ORGANIZATION_ID'}, function (err, members) { + * console.log(members); + * }); + * @param {object} params Organization parameters + * @param {string} params.id Organization ID + * @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from. + * @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getMembers(params, callback) { + return this.members.getAll(params, callback); + } + + /** + * Add members in an organization + * + * @example + * var params = { id :'ORGANIZATION_ID'}; + * var data = { members: [ 'USER_ID1', 'USER_ID2' ] } + * management.organizations.addMembers(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {object} data add members data + * @param {Array} data.members Array of user IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + addMembers(params, data, cb) { + data = data || {}; + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.members.create(params, data, cb); + } + + return this.members.create(params, data); + } + + /** + * Remove members from an organization + * + * @example + * var params = { id :'ORGANIZATION_ID' }; + * var data = { members: [ 'USER_ID1', 'USER_ID2' ] } + * + * management.organizations.removeMembers(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {object} data add members data + * @param {Array} data.members Array of user IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removeMembers(params, data, cb) { + data = data || {}; + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.members.delete(params, data, cb); + } + + return this.members.delete(params, data); + } + + /** + *Organization Invites + */ + + /** + * Get Invites in a Organization + * + * @example + * var params = {id : 'ORGANIZATION_ID'} + * @example + * This method takes an organization ID and returns the invites in an Organization + * + * + * management.organizations.getInvitations( {id : 'ORGANIZATION_ID'}, function (err, invites) { + * console.log(invites); + * @param callback + * }); + * @param {object} params Organization parameters + * @param {string} params.id Organization ID + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from. + * @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50. + * @param {string} [params.fields] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. + * @param {boolean} [params.include_fields] Whether specified fields are to be included (true) or excluded (false). Defaults to true. + * @param {string} [params.sort] Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getInvitations(params, callback) { + return this.invitations.getAll(params, callback); + } + + /** + * Get an Invitation in a Organization + * + * @example + * var params = {id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'} + * @param callback + * @example + * This methods takes the organization ID and user ID and returns the invitation + * + * + * management.organizations.getInvitation({id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}, function (err, invite) { + * console.log(invite); + * }); + * @param {object} params Organization parameters + * @param {string} params.id Organization ID + * @param {string} params.invitation_id Invitation ID + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getInvitation(params, callback) { + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (!params.invitation_id) { + throw new ArgumentError('The invitation ID passed in params cannot be null or undefined'); + } + if (typeof params.invitation_id !== 'string') { + throw new ArgumentError('The invitation ID has to be a string'); + } + + return this.invitations.get(params, callback); + } + + /** + * Create an invitation in an organization + * + * @example + * var params = { id :'ORGANIZATION_ID'}; + * var data = { + * client_id: CLIENT_ID, + * invitee: { email: 'invitee@example.com' }, + * inviter: { name: 'John Doe' } + * }; + * + * management.organizations.createInvitation(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {Array} data Invitation data + * @param {object} data.inviter The person who is sending the invite. + * @param {string} data.inviter.name Name of the person who is sending the invite + * @param {object} data.invitee Invitee to whom invitation is intended for + * @param {object} data.invitee.email Email of the invitee to whom invitation is intended for + * @param {string} data.client_id Auth0 client used to resolve the default application login URI. This endpoint must expect &invitation=... and &organization=... parameters (added by API2) to continue the flow with /authorize. If client_id does not have configured login URI, use the tenant level default login route if configured, otherwise return 400 + * @param {string} [data.connection_id] Force user to authenticate against a specific identity provider. + * @param {object} [data.app_metadata] Application metadata to be assigned to the user after accept the invitation. + * @param {object} [data.user_metadata] User metadata to be assigned to the user after accept the invitation. + * @param {Array} [data.roles] List of roles to be assigned to the user + * @param {number} [data.ttl_sec] Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Upper limit on ttl_sec is 30 days. + * @param {boolean} [data.send_invitation_email] Whether the user will receive an invitation email (true) or no email (false). Default is true. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createInvitation(params, data, cb) { + data = data || []; + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.invitations.create(params, data, cb); + } + + return this.invitations.create(params, data); + } + + /** + * Delete an invitation from an organization + * + * @example + * var params = { id :'ORGANIZATION_ID', invitation_id: 'INVITATION_ID }; + * + * management.organizations.deleteInvitation(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {string} params.invitation_id Invitation ID + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteInvitation(params, cb) { + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (!params.invitation_id) { + throw new ArgumentError('The invitation ID passed in params cannot be null or undefined'); + } + if (typeof params.invitation_id !== 'string') { + throw new ArgumentError('The invitation ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.invitations.delete(params, {}, cb); + } + + return this.invitations.delete(params, {}); + } + + /** + *Organization Roles Membership + */ + + /** + * Get Roles from a Member in a Organization + * + * @example + * var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'} + * @param callback + * @example + * This methods takes the organization ID and user ID and returns the roles + * + * + * management.organizations.getMemberRoles( {id : 'ORGANIZATION_ID', user_id: 'user_id'}, function (err, roles) { + * console.log(roles); + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {string} params.user_id ID of the user. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getMemberRoles(params, callback) { + return this.roles.getAll(params, callback); + } + + /** + * Add a Role to a Member in an organization + * + * @example + * var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'}; + * var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]} + * + * management.organizations.addMemberRoles(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {string} params.user_id ID of the user. + * @param {object} data Add member roles data. + * @param {Array} data.roles Array of role IDs. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + addMemberRoles(params, data, cb) { + data = data || {}; + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (!params.user_id) { + throw new ArgumentError('The user ID passed in params cannot be null or undefined'); + } + if (typeof params.user_id !== 'string') { + throw new ArgumentError('The user ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.roles.create(params, data, cb); + } + + return this.roles.create(params, data); + } + + /** + * Remove Roles from a Member of an organization + * + * @example + * var params = { id :'ORGANIZATION_ID', user_id: 'USER_ID }; + * var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]} + * + * management.organizations.removeMemberRoles(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Organization parameters + * @param {string} params.id ID of the Organization. + * @param {string} params.user_id Id of the User + * @param {object} data Remove member roles data. + * @param {Array} data.roles Array of role IDs. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removeMemberRoles(params, data, cb) { + data = data || {}; + params = params || {}; + + if (!params.id) { + throw new ArgumentError('The organization ID passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The organization ID has to be a string'); + } + + if (!params.user_id) { + throw new ArgumentError('The user ID passed in params cannot be null or undefined'); + } + if (typeof params.user_id !== 'string') { + throw new ArgumentError('The user ID has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.roles.delete(params, data, cb); + } + + return this.roles.delete(params, data); + } +} + +module.exports = OrganizationsManager; diff --git a/src/management/PromptsManager.js b/src/management/PromptsManager.js new file mode 100644 index 000000000..14a630f5b --- /dev/null +++ b/src/management/PromptsManager.js @@ -0,0 +1,162 @@ +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); + +/** + * Manages settings related to prompts. + */ +class PromptsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/management/v2#!/Prompts Prompts endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/prompts'); + + /** + * Retrieve custom text for a specific prompt and language. + * {@link https://auth0.com/docs/api/management/v2#!/Prompts/get_custom_text_by_language Custom Text endpoint} + * + * + * @type {external:RestClient} + */ + this.customTextByLanguage = this._getRestClient('/prompts/:prompt/custom-text/:language'); + } + + /** + * Update the prompts settings. + * + * @example + * management.prompts.updateSettings(params, data, function (err, prompts) { + * if (err) { + * // Handle error. + * } + * + * // Updated prompts + * console.log(prompts); + * }); + * @param {object} params Prompts parameters. + * @param {object} data Updated prompts data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateSettings(...args) { + return this.resource.patch(...args); + } + + /** + * Get the prompts settings.. + * + * @example + * management.prompts.getSettings(data, function (err, prompts) { + * if (err) { + * // Handle error. + * } + * + * // Prompts + * console.log(prompts); + * }); + * @param {object} params Prompts parameters. + * @param {object} data Prompts data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getSettings(...args) { + return this.resource.get(...args); + } + + /** + * Retrieve custom text for a specific prompt and language. + * + * @example + * var params = { prompt: PROMPT_NAME, language: LANGUAGE }; + * + * management.prompts.getCustomTextByLanguage(params, function (err, customText) { + * if (err) { + * // Handle error. + * } + * + * console.log('CustomText', customText); + * }); + * @param {object} params Data object. + * @param {string} params.prompt Name of the prompt. + * @param {string} params.language Language to retrieve. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + getCustomTextByLanguage(params, cb) { + params = params || {}; + + if (!params.prompt || typeof params.prompt !== 'string') { + throw new ArgumentError('The prompt parameter must be a string'); + } + + if (!params.language || typeof params.language !== 'string') { + throw new ArgumentError('The language parameter must be a string'); + } + + if (cb && cb instanceof Function) { + return this.customTextByLanguage.get(params, cb); + } + + return this.customTextByLanguage.get(params); + } + + /** + * Set custom text for a specific prompt. + * + * @example + * var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT }; + * + * management.prompts.updateCustomTextByLanguage(params, function (err, customText) { + * if (err) { + * // Handle error. + * } + * + * console.log('CustomText', customText); + * }); + * @param {object} params Data object. + * @param {string} params.prompt Name of the prompt. + * @param {string} params.language Language to retrieve. + * @param {object} params.body An object containing custom dictionaries for a group of screens. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateCustomTextByLanguage(params, cb) { + params = params || {}; + + if (!params.prompt || typeof params.prompt !== 'string') { + throw new ArgumentError('The prompt parameter must be a string'); + } + + if (!params.language || typeof params.language !== 'string') { + throw new ArgumentError('The language parameter must be a string'); + } + + if (!params.body || typeof params.body !== 'object') { + throw new ArgumentError('The body parameter must be an object'); + } + + const options = { + prompt: params.prompt, + language: params.language, + }; + + if (cb && cb instanceof Function) { + return this.customTextByLanguage.update(options, params.body, cb); + } + + return this.customTextByLanguage.update(options, params.body); + } +} + +module.exports = PromptsManager; diff --git a/src/management/ResourceServersManager.js b/src/management/ResourceServersManager.js index 480423aed..01823c20d 100644 --- a/src/management/ResourceServersManager.js +++ b/src/management/ResourceServersManager.js @@ -1,10 +1,6 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * @class ResourceServersManager * Auth0 Resource Servers Manager. * * {@link https://auth0.com/docs/api/management/v2#!/Resource_Servers Resource Servers} represents @@ -12,176 +8,136 @@ var RetryRestClient = require('../RetryRestClient'); * You can learn more about this in the * {@link https://auth0.com/docs/api-auth API Authorization} section of the * documentation. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ +class ResourceServersManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); -var ResourceServersManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide resource server options'); + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/ResourceServers Auth0 Resource Servers endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/resource-servers/:id'); } - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Create an API (Resource Server). + * + * @example + * management.resourceServers.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Resource Server created. + * }); + * @param {object} data Resource Server data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Get all resource servers. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.resourceServers.getAll(params, function (err, resourceServers) { + * console.log(resourceServers.length); + * }); + * @param {object} [params] Resource Servers parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); } /** - * Options object for the Rest Client instance. + * Get a Resource Server. * - * @type {Object} + * @example + * management.resourceServers.get({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) { + * if (err) { + * // Handle error. + * } + * + * console.log(resourceServer); + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - headers: options.headers, - query: { repeatParams: false } - }; + get(...args) { + return this.resource.get(...args); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/ResourceServers Auth0 Resource Servers endpoint}. + * Update an existing resource server. + * + * @example + * var data = { name: 'newResourceServerName' }; + * var params = { id: RESOURCE_SERVER_ID }; + * + * management.resourceServers.update(params, data, function (err, resourceServer) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * console.log(resourceServer.name); // 'newResourceServernName' + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {object} data Updated Resource Server data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/resource-servers/:id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Create an API (Resource Server). - * - * @method create - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * management.resourceServers.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Resource Server created. - * }); - * - * @param {Object} data Resource Server data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'create', 'resource.create'); - -/** - * Get all resource servers. - * - * @method getAll - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.resourceServers.getAll(params, function (err, resourceServers) { - * console.log(resourceServers.length); - * }); - * - * @param {Object} [params] Resource Servers parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'getAll', 'resource.getAll'); - -/** - * Get a Resource Server. - * - * @method get - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * management.resourceServers.get({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) { - * if (err) { - * // Handle error. - * } - * - * console.log(resourceServer); - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'get', 'resource.get'); - -/** - * Update an existing resource server. - * - * @method update - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * var data = { name: 'newResourceServerName' }; - * var params = { id: RESOURCE_SERVER_ID }; - * - * management.resourceServers.update(params, data, function (err, resourceServer) { - * if (err) { - * // Handle error. - * } - * - * console.log(resourceServer.name); // 'newResourceServernName' - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Object} data Updated Resource Server data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'update', 'resource.patch'); + update(...args) { + return this.resource.patch(...args); + } -/** - * Delete an existing Resource Server. - * - * @method delete - * @memberOf module:management.ResourceServersManager.prototype - * - * @example - * management.resourceServers.delete({ id: RESOURCE_SERVER_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Resource Server deleted. - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ResourceServersManager, 'delete', 'resource.delete'); + /** + * Delete an existing Resource Server. + * + * @example + * management.resourceServers.delete({ id: RESOURCE_SERVER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Resource Server deleted. + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } +} module.exports = ResourceServersManager; diff --git a/src/management/RolesManager.js b/src/management/RolesManager.js new file mode 100644 index 000000000..4f2739a43 --- /dev/null +++ b/src/management/RolesManager.js @@ -0,0 +1,329 @@ +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); + +/** + * The role class provides a simple abstraction for performing CRUD operations + * on Auth0 RolesManager. + */ +class RolesManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/v2#!/RolesManager Auth0 RolesManagers}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/roles/:id'); + + this.permissions = this._getRestClient('/roles/:id/permissions'); + + this.users = this._getRestClient('/roles/:id/users'); + } + + /** + * Create a new role. + * + * @example + * management.roles.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Role created. + * }); + * @param {object} data Role data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); + } + + /** + * Get all roles. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.roles.getAll(params, function (err, roles) { + * console.log(roles.length); + * }); + * @param {object} [params] Roles parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.resource.getAll(...args); + } + + /** + * Get an Auth0 role. + * + * @example + * management.roles.get({ id: ROLE_ID }, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(role); + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + get(...args) { + return this.resource.get(...args); + } + + /** + * Update an existing role. + * + * @example + * var data = { name: 'New name' }; + * var params = { id: ROLE_ID }; + * + * // Using auth0 instance. + * management.updateRole(params, data, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(role.name); // 'New name' + * }); + * + * // Using the roles manager directly. + * management.roles.update(params, data, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(role.name); // 'New name' + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {object} data Updated role data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + update(...args) { + return this.resource.patch(...args); + } + + /** + * Delete an existing role. + * + * @example + * management.roles.delete({ id: ROLE_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Role deleted. + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } + + /** + * Get Permissions in a Role + * + * @param params + * @param callback + * @example + * var params = {id : 'ROLE_ID'} + * @example + * This method takes a first argument as the roleId and returns the permissions within that role + * + * + * management.roles.getPermissions( {id : 'ROLE_ID'}, function (err, permissions) { + * console.log(permissions); + * }); + * @param {string} [email] Email address of user(s) to find + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPermissions(params, callback) { + return this.permissions.getAll(params, callback); + } + + /** + * Add permissions in a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.roles.addPermissions(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // permissions added. + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + addPermissions(params, data, cb) { + data = data || {}; + params = params || {}; + + // Require a user ID. + if (!params.id) { + throw new ArgumentError('The roleId passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The role Id has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.permissions.create(params, data, cb); + } + + return this.permissions.create(params, data); + } + + /** + * Remove permissions from a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.roles.removePermissions(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // permissions added. + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + removePermissions(params, data, cb) { + data = data || {}; + params = params || {}; + + // Require a user ID. + if (!params.id) { + throw new ArgumentError('The roleId passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The role Id has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.permissions.delete(params, data, cb); + } + + return this.permissions.delete(params, data); + } + + /** + * Get Users in a Role + * + * @example + * var params = { + * roleId: 'ROLE_ID', + * per_page: 50, + * page: 0 + * }; + * @example + * This method takes a roleId and returns all users within that role. Supports offset (page, per_page) and checkpoint pagination (from, take). You must use checkpoint pagination to retrieve beyond the first 1000 records. + * + * + * management.roles.getUsers(params, function (err, users) { + * console.log(users); + * }); + * @param {string} [roleId] Id of the role + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from. + * @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUsers(params, callback) { + return this.users.getAll(params, callback); + } + + /** + * Assign users to a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "users" : ["userId1","userId2"]}; + * + * management.roles.assignUsers(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // permissions added. + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + assignUsers(params, data, cb) { + data = data || {}; + params = params || {}; + + // Require a user ID. + if (!params.id) { + throw new ArgumentError('The roleId passed in params cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The role Id has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.users.create(params, data, cb); + } + + return this.users.create(params, data); + } +} + +module.exports = RolesManager; diff --git a/src/management/RulesConfigsManager.js b/src/management/RulesConfigsManager.js index 99e81e6e2..b6a9986ee 100644 --- a/src/management/RulesConfigsManager.js +++ b/src/management/RulesConfigsManager.js @@ -1,129 +1,86 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - - -/** - * @class RulesConfigsManager * The rules configs manager class provides a simple abstraction for performing CRUD operations * on Auth0 RulesConfigsManager. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var RulesConfigsManager = function (options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); - } +class RulesConfigsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/v2#!/RulesConfigsManager Auth0 RulesConfigsManager}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/rules-configs/:key'); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Set a new rules config. + * + * @example + * var params = { key: RULE_CONFIG_KEY }; + * var data = { value: RULES_CONFIG_VALUE }; + * + * management.rulesConfigs.set(params, data, function (err, rulesConfig) { + * if (err) { + * // Handle error. + * } + * + * // Rules Config set. + * }); + * @param {object} params Rule Config parameters. + * @param {string} params.key Rule Config key. + * @param {object} data Rule Config Data parameters. + * @param {string} data.value Rule Config Data value. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + set(...args) { + return this.resource.update(...args); } /** - * Options object for the Rest Client instance. + * Get all rules configs. * - * @type {Object} + * @example + * management.rulesConfigs.getAll(function (err, rulesConfig) { + * console.log(rulesConfig.length); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - headers: options.headers, - query: { repeatParams: false } - }; + getAll(...args) { + return this.resource.getAll(...args); + } /** - * Provides an abstraction layer for performing CRUD operations on - * {@link https://auth0.com/docs/api/v2#!/RulesConfigsManager Auth0 RulesConfigsManager}. + * Delete an existing rules config. + * + * @example + * management.rulesConfigs.delete({ key: RULE_CONFIG_KEY }, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * // Rules Config deleted. + * }); + * @param {object} params Rule Configs parameters. + * @param {string} params.key Rule Configs key. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient(options.baseUrl + '/rules-configs/:key', clientOptions, options.tokenProvider); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - - -/** - * Set a new rules config. - * - * @method set - * @memberOf module:management.RulesConfigsManager.prototype - * - * @example - * var params = { key: RULE_CONFIG_KEY }; - * var data = { value: RULES_CONFIG_VALUE }; - * - * management.rulesConfigs.set(params, data, function (err, rulesConfig) { - * if (err) { - * // Handle error. - * } - * - * // Rules Config set. - * }); - * - * @param {Object} params Rule Config parameters. - * @param {String} params.key Rule Config key. - * @param {Object} data Rule Config Data parameters. - * @param {String} data.value Rule Config Data value. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(RulesConfigsManager, 'set', 'resource.update'); - - -/** - * Get all rules configs. - * - * @method getAll - * @memberOf module:management.RulesConfigsManager.prototype - * - * @example - * management.rulesConfigs.getAll(function (err, rulesConfig) { - * console.log(rulesConfig.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(RulesConfigsManager, 'getAll', 'resource.getAll'); - - -/** - * Delete an existing rules config. - * - * @method delete - * @memberOf module:management.RulesConfigsManager.prototype - * - * @example - * management.rulesConfigs.delete({ key: RULE_CONFIG_KEY }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rules Config deleted. - * }); - * - * @param {Object} params Rule Configs parameters. - * @param {String} params.key Rule Configs key. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(RulesConfigsManager, 'delete', 'resource.delete'); + delete(...args) { + return this.resource.delete(...args); + } +} -module.exports = RulesConfigsManager; \ No newline at end of file +module.exports = RulesConfigsManager; diff --git a/src/management/RulesManager.js b/src/management/RulesManager.js index 61d578dfa..97ce98d15 100644 --- a/src/management/RulesManager.js +++ b/src/management/RulesManager.js @@ -1,197 +1,148 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var utils = require('../utils'); -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - -/** - * @class RulesManager * The rule class provides a simple abstraction for performing CRUD operations * on Auth0 RulesManagers. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var RulesManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); - } +class RulesManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Provides an abstraction layer for performing CRUD operations on + * {@link https://auth0.com/docs/api/v2#!/RulesManagers Auth0 RulesManagers}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/rules/:id'); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Create a new rule. + * + * @example + * management.rules.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Rule created. + * }); + * @param {object} data Rule data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(...args) { + return this.resource.create(...args); } /** - * Options object for the Rest Client instance. + * Get all rules. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * * - * @type {Object} + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.rules.getAll(params, function (err, rules) { + * console.log(rules.length); + * }); + * @param {object} [params] Rules parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var clientOptions = { - headers: options.headers, - query: { repeatParams: false } - }; + getAll(...args) { + return this.resource.getAll(...args); + } /** - * Provides an abstraction layer for performing CRUD operations on - * {@link https://auth0.com/docs/api/v2#!/RulesManagers Auth0 RulesManagers}. + * Get an Auth0 rule. + * + * @example + * management.rules.get({ id: RULE_ID }, function (err, rule) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * console.log(rule); + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/rules/:id', - clientOptions, - options.tokenProvider - ); - this.resource = new RetryRestClient(auth0RestClient, options.retry); -}; - -/** - * Create a new rule. - * - * @method create - * @memberOf module:management.RulesManager.prototype - * - * @example - * management.rules.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rule created. - * }); - * - * @param {Object} data Rule data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(RulesManager, 'create', 'resource.create'); - -/** - * Get all rules. - * - * @method getAll - * @memberOf module:management.RulesManager.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.rules.getAll(params, function (err, rules) { - * console.log(rules.length); - * }); - * - * @param {Object} [params] Rules parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(RulesManager, 'getAll', 'resource.getAll'); - -/** - * Get an Auth0 rule. - * - * @method get - * @memberOf module:management.RulesManager.prototype - * - * @example - * management.rules.get({ id: RULE_ID }, function (err, rule) { - * if (err) { - * // Handle error. - * } - * - * console.log(rule); - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(RulesManager, 'get', 'resource.get'); + get(...args) { + return this.resource.get(...args); + } -/** - * Update an existing rule. - * - * @method update - * @memberOf module:management.RulesManager.prototype - * - * @example - * var data = { name: 'New name' }; - * var params = { id: RULE_ID }; - * - * // Using auth0 instance. - * management.updateRule(params, data, function (err, rule) { - * if (err) { - * // Handle error. - * } - * - * console.log(rule.name); // 'New name' - * }); - * - * // Using the rules manager directly. - * management.rules.update(params, data, function (err, rule) { - * if (err) { - * // Handle error. - * } - * - * console.log(rule.name); // 'New name' - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Object} data Updated rule data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(RulesManager, 'update', 'resource.patch'); + /** + * Update an existing rule. + * + * @example + * var data = { name: 'New name' }; + * var params = { id: RULE_ID }; + * + * // Using auth0 instance. + * management.updateRule(params, data, function (err, rule) { + * if (err) { + * // Handle error. + * } + * + * console.log(rule.name); // 'New name' + * }); + * + * // Using the rules manager directly. + * management.rules.update(params, data, function (err, rule) { + * if (err) { + * // Handle error. + * } + * + * console.log(rule.name); // 'New name' + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {object} data Updated rule data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + update(...args) { + return this.resource.patch(...args); + } -/** - * Delete an existing rule. - * - * @method delete - * @memberOf module:management.RulesManager.prototype - * - * @example - * management.rules.delete({ id: RULE_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rule deleted. - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(RulesManager, 'delete', 'resource.delete'); + /** + * Delete an existing rule. + * + * @example + * management.rules.delete({ id: RULE_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Rule deleted. + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + delete(...args) { + return this.resource.delete(...args); + } +} module.exports = RulesManager; diff --git a/src/management/StatsManager.js b/src/management/StatsManager.js index 9dafe9f94..ce3d049a0 100644 --- a/src/management/StatsManager.js +++ b/src/management/StatsManager.js @@ -1,123 +1,84 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - -/** - * @class * Abstracts interaction with the stats endpoint. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var StatsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); - } - - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); - } +class StatsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/stats/:type'); } - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; - /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}. + * Get the daily stats. + * + * @example + * var params = { + * from: '{YYYYMMDD}', // First day included in the stats. + * to: '{YYYYMMDD}' // Last day included in the stats. + * }; * - * @type {external:RestClient} + * management.stats.getDaily(params, function (err, stats) { + * if (err) { + * // Handle error. + * } + * + * console.log(stats); + * }); + * @param {object} params Stats parameters. + * @param {string} params.from The first day in YYYYMMDD format. + * @param {string} params.to The last day in YYYYMMDD format. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/stats/:type', - clientOptions, - options.tokenProvider - ); - this.stats = new RetryRestClient(auth0RestClient, options.retry); -}; + getDaily(params, cb) { + params = params || {}; + params.type = 'daily'; -/** - * Get the daily stats. - * - * @method getDaily - * @memberOf module:management.StatsManager.prototype - * - * @example - * var params = { - * from: '{YYYYMMDD}', // First day included in the stats. - * to: '{YYYYMMDD}' // Last day included in the stats. - * }; - * - * management.stats.getDaily(params, function (err, stats) { - * if (err) { - * // Handle error. - * } - * - * console.log(stats); - * }); - * - * @param {Object} params Stats parameters. - * @param {String} params.from The first day in YYYYMMDD format. - * @param {String} params.to The last day in YYYYMMDD format. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -StatsManager.prototype.getDaily = function(params, cb) { - params = params || {}; - params.type = 'daily'; + if (cb && cb instanceof Function) { + return this.resource.get(params, cb); + } - if (cb && cb instanceof Function) { - return this.stats.get(params, cb); + return this.resource.get(params); } - return this.stats.get(params); -}; + /** + * Get a the active users count. + * + * @example + * management.stats.getActiveUsersCount(function (err, usersCount) { + * if (err) { + * // Handle error. + * } + * + * console.log(usersCount); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getActiveUsersCount(cb) { + const options = { type: 'active-users' }; -/** - * Get a the active users count. - * - * @method getActiveUsersCount - * @memberOf module:management.StatsManager.prototype - * - * @example - * management.stats.getActiveUsersCount(function (err, usersCount) { - * if (err) { - * // Handle error. - * } - * - * console.log(usersCount); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -StatsManager.prototype.getActiveUsersCount = function(cb) { - var options = { type: 'active-users' }; + if (cb && cb instanceof Function) { + return this.resource.get(options, cb); + } - if (cb && cb instanceof Function) { - return this.stats.get(options, cb); + // Return a promise. + return this.resource.get(options); } - - // Return a promise. - return this.stats.get(options); -}; +} module.exports = StatsManager; diff --git a/src/management/TenantManager.js b/src/management/TenantManager.js index a4ee9dbae..26c11624f 100644 --- a/src/management/TenantManager.js +++ b/src/management/TenantManager.js @@ -1,110 +1,76 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ - -/** - * @class * Abstracts interaction with the tenant endpoint. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var TenantManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); - } - - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); - } +class TenantManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/tenants/settings'); } - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; - /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}. + * Update the tenant settings. * - * @type {external:RestClient} + * @example + * management.tenant.updateSettings(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data The new tenant settings. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/tenants/settings', - clientOptions, - options.tokenProvider - ); - this.tenant = new RetryRestClient(auth0RestClient, options.retry); -}; + updateSettings(data, cb) { + if (cb && cb instanceof Function) { + return this.resource.patch({}, data, cb); + } -/** - * Update the tenant settings. - * - * @method updateSettings - * @memberOf module:management.TenantManager.prototype - * - * @example - * management.tenant.updateSettings(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data The new tenant settings. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -TenantManager.prototype.updateSettings = function(data, cb) { - if (cb && cb instanceof Function) { - return this.tenant.patch({}, data, cb); + // Return a promise. + return this.resource.patch({}, data); } - // Return a promise. - return this.tenant.patch({}, data); -}; + /** + * Get the tenant settings.. + * + * @example + * management.tenant.getSettings({ include_fields: true, fields: 'friendly_name' }, function (err, settings) { + * if (err) { + * // Handle error. + * } + * + * console.log(settings); + * }); + * @param {object} [data] Request parameters + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getSettings(data, cb) { + if (data instanceof Function && !cb) { + cb = data; + data = {}; + } + if (cb && cb instanceof Function) { + return this.resource.get(data, cb); + } -/** - * Get the tenant settings.. - * - * @method getSettings - * @memberOf module:management.TenantManager.prototype - * - * @example - * management.tenant.getSettings(function (err, settings) { - * if (err) { - * // Handle error. - * } - * - * console.log(settings); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -TenantManager.prototype.getSettings = function(cb) { - if (cb && cb instanceof Function) { - return this.tenant.get({}, cb); + // Return a promise. + return this.resource.get(data); } - - // Return a promise. - return this.tenant.get({}); -}; +} module.exports = TenantManager; diff --git a/src/management/TicketsManager.js b/src/management/TicketsManager.js index d6e06c919..9aca12102 100644 --- a/src/management/TicketsManager.js +++ b/src/management/TicketsManager.js @@ -1,115 +1,104 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const BaseManager = require('./BaseManager'); /** - * @class * Abstracts interaction with the tickets endpoint. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var TicketsManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); - } - - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); - } +class TicketsManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Tickets Tickets endpoint}. + * + * @type {external:RestClient} + */ + this.resource = this._getRestClient('/tickets/:type'); } - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; - /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Tickets Tickets endpoint}. + * Create a new password change ticket. * - * @type {external:RestClient} + * @example + * var params = { + * result_url: '{REDIRECT_URL}', // Redirect after using the ticket. + * user_id: '{USER_ID}', // Optional. + * email: '{USER_EMAIL}', // Optional. + * new_password: '{PASSWORD}' + * }; + * + * management.tickets.changePassword(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data + * @param {string} [data.result_url] URL the user will be redirected to once ticket is used. + * @param {string} [data.user_id] user_id for whom the ticket should be created. (Conflicts with: connection_id, email) + * @param {string} [data.client_id] ID of the client. + * @param {string} [data.organization_id] ID of the organization. + * @param {string} [data.connection_id] ID of the connection. + * @param {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration. + * @param {string} [data.email] Email of the user. (Requires: connection_id) + * @param {boolean} [data.mark_email_as_verified] Whether to set the email_verified attribute to true (true) or whether it should not be updated (false). + * @param {boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false). + * @param {Function} [cb] Callback function. + * @returns {Promise} */ - var auth0RestClient = new Auth0RestClient( - options.baseUrl + '/tickets/:type', - clientOptions, - options.tokenProvider - ); - this.ticket = new RetryRestClient(auth0RestClient, options.retry); -}; + changePassword(data, cb) { + const params = { type: 'password-change' }; -/** - * Create a new password change ticket. - * - * @method changePassword - * @memberOf module:management.TicketsManager.prototype - * - * @example - * var params = { - * result_url: '{REDIRECT_URL}', // Redirect after using the ticket. - * user_id: '{USER_ID}', // Optional. - * email: '{USER_EMAIL}', // Optional. - * new_password: '{PASSWORD}' - * }; - * - * management.tickets.changePassword(params, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Function} [cb] Callback function. - * @return {Promise} - */ -TicketsManager.prototype.changePassword = function(data, cb) { - var params = { type: 'password-change' }; + if (cb && cb instanceof Function) { + return this.resource.create(params, data, cb); + } - if (cb && cb instanceof Function) { - return this.ticket.create(params, data, cb); + // Return a promise. + return this.resource.create(params, data); } - // Return a promise. - return this.ticket.create(params, data); -}; + /** + * Create an email verification ticket. + * + * @example + * var data = { + * user_id: '{USER_ID}', + * result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used. + * }; + * + * management.tickets.verifyEmail(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data + * @param {string} [data.result_url] URL the user will be redirected to once ticket is used. + * @param {string} data.user_id user_id for whom the ticket should be created. + * @param {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration. + * @param {boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the result_url (true), or not (false). + * @param {object} [data.identity] Used to verify secondary, federated, and passwordless-email identities. + * @param {string} data.identity.user_id user_id of the identity. + * @param {string} data.identity.provider provider of the identity. + * @param {string} [data.client_id] client ID. + * @param {string} [data.organization_id] organization ID. + * @param {Function} [cb] Callback function. + * @returns {Promise} + */ + verifyEmail(data, cb) { + const params = { type: 'email-verification' }; -/** - * Create an email verification ticket. - * - * @method verifyEmail - * @memberOf module:management.TicketsManager.prototype - * - * @example - * var data = { - * user_id: '{USER_ID}', - * result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used. - * }; - * - * management.tickets.verifyEmail(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Function} [cb] Callback function. - * @return {Promise} - */ -TicketsManager.prototype.verifyEmail = function(data, cb) { - var params = { type: 'email-verification' }; + if (cb && cb instanceof Function) { + return this.resource.create(params, data, cb); + } - if (cb && cb instanceof Function) { - return this.ticket.create(params, data, cb); + // Return a promise. + return this.resource.create(params, data); } - - // Return a promise. - return this.ticket.create(params, data); -}; +} module.exports = TicketsManager; diff --git a/src/management/UserBlocksManager.js b/src/management/UserBlocksManager.js new file mode 100644 index 000000000..c57a25fdf --- /dev/null +++ b/src/management/UserBlocksManager.js @@ -0,0 +1,121 @@ +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); + +/** + * Abstracts interaction with the user-blocks endpoint. + */ +class UserBlocksManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + this.userBlocksById = this._getRestClient('/user-blocks/:id'); + + this.userBlocksByIdentifier = this._getRestClient('/user-blocks'); + } + + /** + * Get user blocks by id. + * + * @example + * management.userBlocks.get({ id: USER_ID }, function (err, blocks) { + * if (err) { + * // Handle error. + * } + * + * console.log(blocks); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + get(params, ...restOfArgs) { + if (typeof params !== 'object' || typeof params.id !== 'string') { + throw new ArgumentError('You must provide an user id for the get method'); + } + + return this.userBlocksById.get(params, ...restOfArgs); + } + + /** + * Unblock an user by its id. + * + * @example + * management.userBlocks.delete({ id: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User unblocked. + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + delete(params, ...restOfArgs) { + if (typeof params !== 'object' || typeof params.id !== 'string') { + throw new ArgumentError('You must provide an user id for the delete method'); + } + + return this.userBlocksById.delete(params, ...restOfArgs); + } + + /** + * Get user blocks by identifier. + * + * @example + * management.userBlocks.getByIdentifier({ identifier: USER_ID }, function (err, blocks) { + * if (err) { + * // Handle error. + * } + * + * console.log(blocks); + * }); + * @param {object} params The user data object.. + * @param {string} params.identifier The user identifier, any of: username, phone_number, email. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + getByIdentifier(params, ...restOfArgs) { + if (typeof params !== 'object' || typeof params.identifier !== 'string') { + throw new ArgumentError('You must provide an user identifier for the getByIdentifier method'); + } + + return this.userBlocksByIdentifier.get(params, ...restOfArgs); + } + + /** + * Unblock an user by identifier. + * + * @example + * management.userBlocks.deleteByIdentifier({ identifier: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User unblocked. + * }); + * @param {object} params The user data object.. + * @param {string} params.identifier The user identifier, any of: username, phone_number, email. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + deleteByIdentifier(params, ...restOfArgs) { + if (typeof params !== 'object' || typeof params.identifier !== 'string') { + throw new ArgumentError( + 'You must provide an user identifier for the deleteByIdentifier method' + ); + } + + return this.userBlocksByIdentifier.delete(params, ...restOfArgs); + } +} + +module.exports = UserBlocksManager; diff --git a/src/management/UsersManager.js b/src/management/UsersManager.js index 18f162515..0d7e22383 100644 --- a/src/management/UsersManager.js +++ b/src/management/UsersManager.js @@ -1,626 +1,762 @@ -var ArgumentError = require('rest-facade').ArgumentError; -var Auth0RestClient = require('../Auth0RestClient'); -var RetryRestClient = require('../RetryRestClient'); +const { ArgumentError } = require('rest-facade'); +const BaseManager = require('./BaseManager'); -/** - * Simple facade for consuming a REST API endpoint. - * @external RestClient - * @see https://github.com/ngonzalvez/rest-facade - */ +const { sanitizeArguments } = require('../utils'); /** - * @class * Abstracts interaction with the users endpoint. - * @constructor - * @memberOf module:management - * - * @param {Object} options The client options. - * @param {String} options.baseUrl The URL of the API. - * @param {Object} [options.headers] Headers to be included in all requests. - * @param {Object} [options.retry] Retry Policy Config */ -var UsersManager = function(options) { - if (options === null || typeof options !== 'object') { - throw new ArgumentError('Must provide manager options'); +class UsersManager extends BaseManager { + /** + * @param {object} options The client options. + * @param {string} options.baseUrl The URL of the API. + * @param {object} [options.headers] Headers to be included in all requests. + * @param {object} [options.retry] Retry Policy Config + */ + constructor(options) { + super(options); + + this.users = this._getRestClient('/users/:id'); + + /** + * Provides an abstraction layer for consuming the + * {@link https://auth0.com/docs/api/v2#!/Users/delete_multifactor_by_provider + * Multifactor Provider endpoint}. + * + * @type {external:RestClient} + */ + this.multifactor = this._getRestClient('/users/:id/multifactor/:provider'); + + /** + * Provides a simple abstraction layer for linking user accounts. + * + * @type {external:RestClient} + */ + this.identities = this._getRestClient('/users/:id/identities/:provider/:user_id'); + + /** + * Provides a simple abstraction layer for user logs + * + * @type {external:RestClient} + */ + this.userLogs = this._getRestClient('/users/:id/logs'); + + /** + * Provides an abstraction layer for retrieving Guardian enrollments. + * + * @type {external:RestClient} + */ + this.enrollments = this._getRestClient('/users/:id/enrollments'); + + /** + * Provides an abstraction layer for the new "users-by-email" API + * + * @type {external:RestClient} + */ + this.usersByEmail = this._getRestClient('/users-by-email'); + + /** + * Provides an abstraction layer for regenerating Guardian recovery codes. + * + * @type {external:RestClient} + */ + this.recoveryCodeRegenerations = this._getRestClient('/users/:id/recovery-code-regeneration'); + + /** + * Provides an abstraction layer for invalidating all remembered browsers for MFA. + * + * @type {external:RestClient} + */ + this.invalidateRememberBrowsers = this._getRestClient( + '/users/:id/multifactor/actions/invalidate-remember-browser' + ); + + /** + * Provides an abstraction layer for CRD on roles for a user + * + * @type {external:RestClient} + */ + this.roles = this._getRestClient('/users/:id/roles'); + + /** + * Provides an abstraction layer for CRD on permissions directly on a user + * + * @type {external:RestClient} + */ + this.permissions = this._getRestClient('/users/:id/permissions'); + + this.organizations = this._getRestClient('/users/:id/organizations'); } - if (options.baseUrl === null || options.baseUrl === undefined) { - throw new ArgumentError('Must provide a base URL for the API'); + /** + * Create a new user. + * + * @example + * management.users.create(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User created. + * }); + * @param {object} data User data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + create(data, cb) { + if (cb && cb instanceof Function) { + return this.users.create(data, cb); + } + + return this.users.create(data); } - if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) { - throw new ArgumentError('The provided base URL is invalid'); + /** + * Get all users. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings and the search query. If pagination options are + * not present, the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.users.getAll(params, function (err, users) { + * console.log(users.length); + * }); + * @param {object} [params] Users params. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getAll(...args) { + return this.users.getAll(...args); } - var clientOptions = { - errorFormatter: { message: 'message', name: 'error' }, - headers: options.headers, - query: { repeatParams: false } - }; + /** + * Get Users by an Email Address + * + * @example + * This method takes a first argument as the Email address to look for + * users, and uses the /users-by-email API, not the search API + * + * + * management.users.getByEmail('email@address', function (err, users) { + * console.log(users); + * }); + * @param {string} [email] Email address of user(s) to find + * @param {object} [options] Additional options to pass to the endpoint + * @param {string} [options.fields] Comma-separated list of fields to include or exclude in the result + * @param {boolean} [options.include_fields] Whether specified fields are to be included (true) or excluded (false). Defaults to true. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getByEmail(email, options, cb) { + const { options: sanitizedOptions, cb: sanitizedCb } = sanitizeArguments(options, cb); - var usersAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/users/:id', - clientOptions, - options.tokenProvider - ); - this.users = new RetryRestClient(usersAuth0RestClient, options.retry); + return this.usersByEmail.getAll({ email, ...sanitizedOptions }, sanitizedCb); + } /** - * Provides an abstraction layer for consuming the - * {@link https://auth0.com/docs/api/v2#!/Users/delete_multifactor_by_provider - * Multifactor Provider endpoint}. + * Get a user by its id. * - * @type {external:RestClient} + * @example + * management.users.get({ id: USER_ID }, function (err, user) { + * console.log(user); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - var multifactorAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/users/:id/multifactor/:provider', - clientOptions, - options.tokenProvider - ); - this.multifactor = new RetryRestClient(multifactorAuth0RestClient, options.retry); + get(...args) { + return this.users.get(...args); + } /** - * Provides a simple abstraction layer for linking user accounts. + * Update a user by its id. + * + * @example + * var params = { id: USER_ID }; + * + * management.users.update(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user parameters. + * @param {string} params.id The user id. + * @param {object} data New user data. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} */ - var identitiesAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/users/:id/identities/:provider/:user_id', - clientOptions, - options.tokenProvider - ); - this.identities = new RetryRestClient(identitiesAuth0RestClient, options.retry); + update(...args) { + return this.users.patch(...args); + } /** - * Provides a simple abstraction layer for user logs + * Update the user metadata. + * + * @example + * var params = { id: USER_ID }; + * var metadata = { + * address: '123th Node.js Street' + * }; * - * @type {external:RestClient} + * management.users.updateUserMetadata(params, metadata, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {object} metadata New user metadata. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} */ - var userLogsAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/users/:id/logs', - clientOptions, - options.tokenProvider - ); - this.userLogs = new RetryRestClient(userLogsAuth0RestClient, options.retry); + updateUserMetadata(params, metadata, cb) { + const data = { + user_metadata: metadata, + }; + + if (cb && cb instanceof Function) { + return this.users.patch(params, data, cb); + } + + return this.users.patch(params, data); + } /** - * Provides an abstraction layer for retrieving Guardian enrollments. + * Update the app metadata. * - * @type {external:RestClient} + * @example + * var params = { id: USER_ID }; + * var metadata = { + * foo: 'bar' + * }; + * + * management.users.updateAppMetadata(params, metadata, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {object} metadata New app metadata. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} */ - var enrollmentsAuth0RestClient = new Auth0RestClient( - options.baseUrl + '/users/:id/enrollments', - clientOptions, - options.tokenProvider - ); - this.enrollments = new RetryRestClient(enrollmentsAuth0RestClient, options.retry); + updateAppMetadata(params, metadata, cb) { + const data = { + app_metadata: metadata, + }; + + if (cb && cb instanceof Function) { + return this.users.patch(params, data, cb); + } + + return this.users.patch(params, data); + } /** - * Provides an abstraction layer for the new "users-by-email" API + * Delete a user by its id. * - * @type {external:RestClient} + * @example + * management.users.delete({ id: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User deleted. + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} */ - var usersByEmailClient = new Auth0RestClient( - options.baseUrl + '/users-by-email', - clientOptions, - options.tokenProvider - ); - this.usersByEmail = new RetryRestClient(usersByEmailClient, options.retry); + delete(params, ...restOfArgs) { + if (typeof params !== 'object' || typeof params.id !== 'string') { + throw new ArgumentError('You must provide an id for the delete method'); + } + + return this.users.delete(params, ...restOfArgs); + } /** - * Provides an abstraction layer for regenerating Guardian recovery codes. + * Delete all users. + * + * @example + * management.users.deleteAll(function (err) { + * if (err) { + * // Handle error. + * } * - * @type {external:RestClient} + * // Users deleted + * }); + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + * @deprecated This method will be removed in the next major release. */ - var recoveryCodeRegenerationAuth0RestClients = new Auth0RestClient( - options.baseUrl + '/users/:id/recovery-code-regeneration', - clientOptions, - options.tokenProvider - ); - this.recoveryCodeRegenerations = new RetryRestClient( - recoveryCodeRegenerationAuth0RestClients, - options.retry - ); -}; + deleteAll(cb, ...restOfArgs) { + if (typeof cb !== 'function') { + const errorMsg = 'The deleteAll method only accepts a callback as argument'; -/** - * Create a new user. - * - * @method create - * @memberOf module:management.UsersManager.prototype - * - * @example - * management.users.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // User created. - * }); - * - * @param {Object} data User data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.create = function(data, cb) { - if (cb && cb instanceof Function) { - return this.users.create(data, cb); - } + throw new ArgumentError(errorMsg); + } - return this.users.create(data); -}; + return this.users.delete(cb, ...restOfArgs); + } -/** - * Get all users. - * - * @method getAll - * @memberOf module:management.UsersManager.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings and the search query. If pagination options are - * not present, the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.users.getAll(params, function (err, users) { - * console.log(users.length); - * }); - * - * @param {Object} [params] Users params. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.getAll = function(params) { - return this.users.getAll.apply(this.users, arguments); -}; + /** + * Delete a multifactor provider. + * + * @example + * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; + * + * management.users.deleteMultifactorProvider(params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users accounts unlinked. + * }); + * @param {object} params Data object. + * @param {string} params.id The user id. + * @param {string} params.provider Multifactor provider. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + deleteMultifactorProvider(params, cb) { + params = params || {}; -/** - * Get Users by an Email Address - * - * @method getByEmail - * @memberOf module:management.UsersManager.prototype - * - * @example - * This method takes a first argument as the Email address to look for - * users, and uses the /users-by-email API, not the search API - * - * - * management.users.getByEmail('email@address', function (err, users) { - * console.log(users); - * }); - * - * @param {String} [email] Email address of user(s) to find - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.getByEmail = function(email, callback) { - return this.usersByEmail.getAll({ email }, callback); -}; + if (!params.id || typeof params.id !== 'string') { + throw new ArgumentError('The id parameter must be a valid user id'); + } -/** - * Get a user by its id. - * - * @method get - * @memberOf module:management.UsersManager.prototype - * - * @example - * management.users.get({ id: USER_ID }, function (err, user) { - * console.log(user); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.get = function() { - return this.users.get.apply(this.users, arguments); -}; + if (!params.provider || typeof params.provider !== 'string') { + throw new ArgumentError('Must specify a provider'); + } -/** - * Update a user by its id. - * - * @method update - * @memberOf module:management.UsersManager.prototype - * - * @example - * var params = { id: USER_ID }; - * - * management.users.update(params, data, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user parameters. - * @param {String} params.id The user id. - * @param {Object} data New user data. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -UsersManager.prototype.update = function() { - return this.users.patch.apply(this.users, arguments); -}; + if (cb && cb instanceof Function) { + return this.multifactor.delete(params, cb); + } -/** - * Update the user metadata. - * - * @method updateUserMetadata - * @memberOf module:management.UsersManager.prototype - * - * @example - * var params = { id: USER_ID }; - * var metadata = { - * address: '123th Node.js Street' - * }; - * - * management.users.updateUserMetadata(params, metadata, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Object} metadata New user metadata. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -UsersManager.prototype.updateUserMetadata = function(params, metadata, cb) { - var data = { - user_metadata: metadata - }; + return this.multifactor.delete(params); + } - if (cb && cb instanceof Function) { - return this.users.patch(params, data, cb); + /** + * Link the user with another account. + * + * @example + * var userId = 'USER_ID'; + * var params = { + * user_id: 'OTHER_USER_ID', + * connection_id: 'CONNECTION_ID' + * }; + * + * management.users.link(userId, params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users linked. + * }); + * @param {string} userId ID of the primary user. + * @param {object} params Secondary user data. + * @param {string} params.user_id ID of the user to be linked. + * @param {string} params.connection_id ID of the connection to be used. + * @param {string} params.provider Identity provider of the secondary user account being linked. + * @param {string} params.link_with JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + link(userId, params, cb) { + const query = { id: userId }; + params = params || {}; + + // Require a user ID. + if (!userId) { + throw new ArgumentError('The userId cannot be null or undefined'); + } + if (typeof userId !== 'string') { + throw new ArgumentError('The userId has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.identities.create(query, params, cb); + } + + return this.identities.create(query, params); } - return this.users.patch(params, data); -}; + /** + * Unlink the given accounts. + * + * @example + * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID }; + * + * management.users.unlink(params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users accounts unlinked. + * }); + * @param {object} params Linked users data. + * @param {string} params.id Primary user ID. + * @param {string} params.provider Identity provider in use. + * @param {string} params.user_id Secondary user ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + unlink(params, cb) { + params = params || {}; + + if (!params.id || typeof params.id !== 'string') { + throw new ArgumentError('id field is required'); + } -/** - * Update the app metadata. - * - * @method updateAppMetadata - * @memberOf module:management.UsersManager.prototype - * - * @example - * var params = { id: USER_ID }; - * var metadata = { - * foo: 'bar' - * }; - * - * management.users.updateAppMetadata(params, metadata, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Object} metadata New app metadata. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -UsersManager.prototype.updateAppMetadata = function(params, metadata, cb) { - var data = { - app_metadata: metadata - }; + if (!params.user_id || typeof params.user_id !== 'string') { + throw new ArgumentError('user_id field is required'); + } - if (cb && cb instanceof Function) { - return this.users.patch(params, data, cb); - } + if (!params.provider || typeof params.provider !== 'string') { + throw new ArgumentError('provider field is required'); + } - return this.users.patch(params, data); -}; + if (cb && cb instanceof Function) { + return this.identities.delete(params, cb); + } -/** - * Delete a user by its id. - * - * @method delete - * @memberOf module:management.UsersManager.prototype - * - * @example - * management.users.delete({ id: USER_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // User deleted. - * }); - * - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -UsersManager.prototype.delete = function(params) { - if (typeof params !== 'object' || typeof params.id !== 'string') { - throw new ArgumentError('You must provide an id for the delete method'); + return this.identities.delete(params); } - return this.users.delete.apply(this.users, arguments); -}; + /** + * Get user's log events. + * + * @example + * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; + * + * management.users.logs(params, function (err, logs) { + * if (err) { + * // Handle error. + * } + * + * console.log(logs); + * }); + * @param {object} params Get logs data. + * @param {string} params.id User id. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + logs(params, cb) { + params = params || {}; -/** - * Delete all users. - * - * @method deleteAll - * @memberOf module:management.UsersManager.prototype - * - * @example - * management.users.deleteAll(function (err) { - * if (err) { - * // Handle error. - * } - * - * // Users deleted - * }); - * - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - * - * @deprecated This method will be removed in the next major release. - */ -UsersManager.prototype.deleteAll = function(cb) { - if (typeof cb !== 'function') { - var errorMsg = 'The deleteAll method only accepts a callback as argument'; + if (!params.id || typeof params.id !== 'string') { + throw new ArgumentError('id field is required'); + } + + return this.userLogs.get(params, cb); + } - throw new ArgumentError(errorMsg); + /** + * Get a list of Guardian enrollments. + * + * @example + * management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) { + * console.log(enrollments); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianEnrollments(...args) { + return this.enrollments.get(...args); } - return this.users.delete.apply(this.users, arguments); -}; + /** + * Generate new Guardian recovery code. + * + * @example + * management.users.regenerateRecoveryCode("USER_ID", function (err, result) { + * console.log(result.recovery_code); + * }); + * @param {object} params Get logs data. + * @param {string} params.id User id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + regenerateRecoveryCode(params, cb) { + if (!params || !params.id) { + throw new ArgumentError('The userId cannot be null or undefined'); + } -/** - * Delete a multifactor provider. - * - * @method deleteMultifactorProvider - * @memberOf module:management.UsersManager.prototype - * - * @example - * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; - * - * management.users.deleteMultifactorProvider(params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users accounts unlinked. - * }); - * - * @param {Object} params Data object. - * @param {String} params.id The user id. - * @param {String} params.provider Multifactor provider. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -UsersManager.prototype.deleteMultifactorProvider = function(params, cb) { - params = params || {}; + if (cb && cb instanceof Function) { + return this.recoveryCodeRegenerations.create(params, {}, cb); + } - if (!params.id || typeof params.id !== 'string') { - throw new ArgumentError('The id parameter must be a valid user id'); + return this.recoveryCodeRegenerations.create(params, {}); } - if (!params.provider || typeof params.provider !== 'string') { - throw new ArgumentError('Must specify a provider'); + /** + * Invalidate all remembered browsers for MFA. + * + * @example + * management.users.invalidateRememberBrowser({ id: USER_ID }, function (err, result) { + * if (err) { + * // Handle error. + * } + * + * // Invalidated all remembered browsers. + * }); + * @param {object} params The user data object. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + invalidateRememberBrowser(params, cb) { + if (!params || !params.id) { + throw new ArgumentError('The userId cannot be null or undefined'); + } + + if (cb && cb instanceof Function) { + return this.invalidateRememberBrowsers.create(params, {}, cb); + } + + return this.invalidateRememberBrowsers.create(params, {}); } - if (cb && cb instanceof Function) { - return this.multifactor.delete(params, cb); + /** + * Get a list of roles for a user. + * + * @example + * management.users.getRoles({ id: USER_ID }, function (err, roles) { + * console.log(roles); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRoles(...args) { + return this.roles.getAll(...args); } - return this.multifactor.delete(params); -}; + /** + * Assign roles to a user + * + * @example + * var params = { id : 'USER_ID'; + * var data = { "roles" : ["roleId1", "roleID2"]}; + * + * management.users.assignRoles(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // roles added. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of role IDs + * @param {string} data.roles Array of role IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + + assignRoles(params, data, cb) { + const query = params || {}; + data = data || {}; -/** - * Link the user with another account. - * - * @method link - * @memberOf module:management.UsersManager.prototype - * - * @example - * var userId = 'USER_ID'; - * var params = { - * user_id: 'OTHER_USER_ID', - * connection_id: 'CONNECTION_ID' - * }; - * - * management.users.link(userId, params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users linked. - * }); - * - * @param {String} userId ID of the primary user. - * @param {Object} params Secondary user data. - * @param {String} params.user_id ID of the user to be linked. - * @param {String} params.connection_id ID of the connection to be used. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.link = function(userId, params, cb) { - var query = { id: userId }; - params = params || {}; + // Require a user ID. + if (!params.id) { + throw new ArgumentError('The user_id cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The user_id has to be a string'); + } - // Require a user ID. - if (!userId) { - throw new ArgumentError('The userId cannot be null or undefined'); - } - if (typeof userId !== 'string') { - throw new ArgumentError('The userId has to be a string'); - } + if (cb && cb instanceof Function) { + return this.roles.create(query, data, cb); + } - if (cb && cb instanceof Function) { - return this.identities.create(query, params, cb); + return this.roles.create(query, data); } - return this.identities.create(query, params); -}; + /** + * Remove roles from a user + * + * @example + * var params = { id : 'USER_ID'; + * var data = { "roles" : ["roleId1", "roleID2"]}; + * + * management.users.removeRoles(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // roles removed. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of role IDs + * @param {string} data.roles Array of role IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ -/** - * Unlink the given accounts. - * - * @method unlink - * @memberOf module:management.UsersManager.prototype - * - * @example - * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID }; - * - * management.users.unlink(params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users accounts unlinked. - * }); - * - * @param {Object} params Linked users data. - * @param {String} params.id Primary user ID. - * @param {String} params.provider Identity provider in use. - * @param {String} params.user_id Secondary user ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.unlink = function(params, cb) { - params = params || {}; + removeRoles(params, data, cb) { + const query = params || {}; + data = data || {}; - if (!params.id || typeof params.id !== 'string') { - throw new ArgumentError('id field is required'); - } + // Require a user ID. + if (!params.id) { + throw new ArgumentError('The user_id cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The user_id has to be a string'); + } - if (!params.user_id || typeof params.user_id !== 'string') { - throw new ArgumentError('user_id field is required'); - } + if (cb && cb instanceof Function) { + return this.roles.delete(query, data, cb); + } - if (!params.provider || typeof params.provider !== 'string') { - throw new ArgumentError('provider field is required'); + return this.roles.delete(query, data); } - if (cb && cb instanceof Function) { - return this.identities.delete(params, cb); + /** + * Get a list of permissions for a user. + * + * @example + * management.users.getPermissions({ id: USER_ID }, function (err, permissions) { + * console.log(permissions); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPermissions(...args) { + return this.permissions.getAll(...args); } - return this.identities.delete(params); -}; + /** + * Assign permissions to a user + * + * @example + * var params = { id : 'USER_ID'; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.users.assignPermissions(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // permissions added. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of permissions + * @param {string} data.permissions Array of permission IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ -/** - * Get user's log events. - * - * @method logs - * @memberOf module:management.UsersManager.prototype - * - * @example - * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; - * - * management.users.logs(params, function (err, logs) { - * if (err) { - * // Handle error. - * } - * - * console.log(logs); - * }); - * - * @param {Object} params Get logs data. - * @param {String} params.id User id. - * @param {Number} params.per_page Number of results per page. - * @param {Number} params.page Page number, zero indexed. - * @param {String} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. - * @param {Boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.logs = function(params, cb) { - params = params || {}; + assignPermissions(params, data, cb) { + const query = params || {}; + data = data || {}; + + // Require a user ID. + if (!params.id) { + throw new ArgumentError('The user_id cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The user_id has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.permissions.create(query, data, cb); + } - if (!params.id || typeof params.id !== 'string') { - throw new ArgumentError('id field is required'); + return this.permissions.create(query, data); } - return this.userLogs.get(params, cb); -}; + /** + * Remove permissions from a user + * + * @example + * var params = { id : 'USER_ID'; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.users.removePermissions(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // permissions removed. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {object} data data object containing list of permission IDs + * @param {string} data.permissions Array of permission IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ -/** - * Get a list of Guardian enrollments. - * - * @method getGuardianEnrollments - * @memberOf module:management.UsersManager.prototype - * - * @example - * management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) { - * console.log(enrollments); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.getGuardianEnrollments = function() { - return this.enrollments.get.apply(this.enrollments, arguments); -}; + removePermissions(params, data, cb) { + const query = params || {}; + data = data || {}; -/** - * Generate new Guardian recovery code. - * - * @method regenerateRecoveryCode - * @memberOf module:management.UsersManager.prototype - * - * @example - * management.users.regenerateRecoveryCode("USER_ID", function (err, result) { - * console.log(result.recovery_code); - * }); - * - * @param {Object} params Get logs data. - * @param {String} params.id User id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -UsersManager.prototype.regenerateRecoveryCode = function(params, cb) { - if (!params || !params.id) { - throw new ArgumentError('The userId cannot be null or undefined'); - } + // Require a user ID. + if (!params.id) { + throw new ArgumentError('The user_id cannot be null or undefined'); + } + if (typeof params.id !== 'string') { + throw new ArgumentError('The user_id has to be a string'); + } + + if (cb && cb instanceof Function) { + return this.permissions.delete(query, data, cb); + } - if (cb && cb instanceof Function) { - return this.recoveryCodeRegenerations.create(params, {}, cb); + return this.permissions.delete(query, data); } - return this.recoveryCodeRegenerations.create(params, {}); -}; + /** + * Get a list of organizations for a user. + * + * @example + * management.users.getUserOrganizations({ id: USER_ID }, function (err, orgs) { + * console.log(orgs); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUserOrganizations(...args) { + return this.organizations.getAll(...args); + } +} module.exports = UsersManager; diff --git a/src/management/index.js b/src/management/index.js index b9bce9cf0..70c5325e0 100644 --- a/src/management/index.js +++ b/src/management/index.js @@ -1,47 +1,50 @@ -/** @module management */ - -var util = require('util'); - -var pkg = require('../../package.json'); -var utils = require('../utils'); -var jsonToBase64 = utils.jsonToBase64; -var ArgumentError = require('rest-facade').ArgumentError; -var assign = Object.assign || require('object.assign'); +const util = require('util'); +const utils = require('../utils'); +const { jsonToBase64, generateClientInfo } = utils; +const { ArgumentError } = require('rest-facade'); // Managers. -var ClientsManager = require('./ClientsManager'); -var ClientGrantsManager = require('./ClientGrantsManager'); -var UsersManager = require('./UsersManager'); -var ConnectionsManager = require('./ConnectionsManager'); -var BlacklistedTokensManager = require('./BlacklistedTokensManager'); -var RulesManager = require('./RulesManager'); -var DeviceCredentialsManager = require('./DeviceCredentialsManager'); -var EmailProviderManager = require('./EmailProviderManager'); -var StatsManager = require('./StatsManager'); -var TenantManager = require('./TenantManager'); -var JobsManager = require('./JobsManager'); -var TicketsManager = require('./TicketsManager'); -var LogsManager = require('./LogsManager'); -var ResourceServersManager = require('./ResourceServersManager'); -var ManagementTokenProvider = require('./ManagementTokenProvider'); -var RulesConfigsManager = require('./RulesConfigsManager'); -var EmailTemplatesManager = require('./EmailTemplatesManager'); -var GuardianManager = require('./GuardianManager'); -var CustomDomainsManager = require('./CustomDomainsManager'); - -var BASE_URL_FORMAT = 'https://%s/api/v2'; -var MANAGEMENT_API_AUD_FORMAT = 'https://%s/api/v2/'; +const ClientsManager = require('./ClientsManager'); +const ClientGrantsManager = require('./ClientGrantsManager'); +const GrantsManager = require('./GrantsManager'); +const UsersManager = require('./UsersManager'); +const UserBlocksManager = require('./UserBlocksManager'); +const ConnectionsManager = require('./ConnectionsManager'); +const AttackProtectionManager = require('./AttackProtectionManager'); +const BlacklistedTokensManager = require('./BlacklistedTokensManager'); +const RulesManager = require('./RulesManager'); +const DeviceCredentialsManager = require('./DeviceCredentialsManager'); +const EmailProviderManager = require('./EmailProviderManager'); +const StatsManager = require('./StatsManager'); +const TenantManager = require('./TenantManager'); +const JobsManager = require('./JobsManager'); +const TicketsManager = require('./TicketsManager'); +const LogsManager = require('./LogsManager'); +const LogStreamsManager = require('./LogStreamsManager'); +const ResourceServersManager = require('./ResourceServersManager'); +const ManagementTokenProvider = require('./ManagementTokenProvider'); +const RulesConfigsManager = require('./RulesConfigsManager'); +const EmailTemplatesManager = require('./EmailTemplatesManager'); +const GuardianManager = require('./GuardianManager'); +const CustomDomainsManager = require('./CustomDomainsManager'); +const RolesManager = require('./RolesManager'); +const HooksManager = require('./HooksManager'); +const BrandingManager = require('./BrandingManager'); +const MigrationsManager = require('./MigrationsManager'); +const PromptsManager = require('./PromptsManager'); +const ActionsManager = require('./ActionsManager'); +const OrganizationsManager = require('./OrganizationsManager'); + +const BASE_URL_FORMAT = 'https://%s/api/v2'; +const MANAGEMENT_API_AUD_FORMAT = 'https://%s/api/v2/'; /** - * @class ManagementClient * Management API SDK. * * The Auth0 Management API is meant to be used by back-end servers or trusted * parties performing administrative tasks. Generally speaking, anything that * can be done through the Auth0 dashboard (and more) can also be done through * this API. - * @constructor - * @memberOf module:management * * @example * Initialize your client class with an API v2 token (you can generate one @@ -53,8 +56,6 @@ var MANAGEMENT_API_AUD_FORMAT = 'https://%s/api/v2/'; * domain: '{YOUR_ACCOUNT}.auth0.com', * token: '{YOUR_API_V2_TOKEN}' * }); - * - * * @example * Initialize your client class, by using a Non Interactive Client to fetch an access_token * via the Client Credentials Grant. @@ -72,2126 +73,3308 @@ var MANAGEMENT_API_AUD_FORMAT = 'https://%s/api/v2/'; * cacheTTLInSeconds: 10 * } * }); - * - * @param {Object} options Options for the ManagementClient SDK. - * If a token is provided only the domain is required, other parameters are ignored. - * If no token is provided domain, clientId, clientSecret and scopes are required - * @param {String} options.domain ManagementClient server domain. - * @param {String} [options.token] API access token. - * @param {String} [options.clientId] Management API Non Interactive Client Id. - * @param {String} [options.clientSecret] Management API Non Interactive Client Secret. - * @param {String} [options.audience] Management API Audience. By default is your domain's, e.g. the domain is `tenant.auth0.com` and the audience is `http://tenant.auth0.com/api/v2/` - * @param {String} [options.scope] Management API Scopes. - * @param {Boolean} [options.tokenProvider.enableCache=true] Enabled or Disable Cache. - * @param {Number} [options.tokenProvider.cacheTTLInSeconds] By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden. - * @param {Boolean} [options.retry.enabled=true] Enabled or Disable Retry Policy functionality. - * @param {Number} [options.retry.maxRetries=10] Retry failed requests X times. - * */ -var ManagementClient = function(options) { - if (!options || typeof options !== 'object') { - throw new ArgumentError('Management API SDK options must be an object'); - } - - if (!options.domain || options.domain.length === 0) { - throw new ArgumentError('Must provide a domain'); - } - - var baseUrl = util.format(BASE_URL_FORMAT, options.domain); - var managerOptions = { - headers: { - 'User-agent': 'node.js/' + process.version.replace('v', ''), - 'Content-Type': 'application/json' - }, - baseUrl: baseUrl - }; - - if (options.token === undefined) { - var config = assign( - { audience: util.format(MANAGEMENT_API_AUD_FORMAT, options.domain) }, - options - ); - - if (options.tokenProvider) { - config.enableCache = options.tokenProvider.enableCache; - config.cacheTTLInSeconds = options.tokenProvider.cacheTTLInSeconds; - delete config.tokenProvider; +class ManagementClient { + /** + * @param {object} options Options for the ManagementClient SDK. + * If a token is provided only the domain is required, other parameters are ignored. + * If no token is provided domain, clientId, clientSecret and scopes are required + * @param {string} options.domain ManagementClient server domain. + * @param {string} [options.token] API access token. + * @param {string} [options.clientId] Management API Non Interactive Client Id. + * @param {string} [options.clientSecret] Management API Non Interactive Client Secret. + * @param {string} [options.audience] Management API Audience. By default is your domain's, e.g. the domain is `tenant.auth0.com` and the audience is `http://tenant.auth0.com/api/v2/` + * @param {string} [options.scope] Management API Scopes. + * @param {boolean} [options.tokenProvider.enableCache=true] Enabled or Disable Cache. + * @param {number} [options.tokenProvider.cacheTTLInSeconds] By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden. + * @param {boolean} [options.retry.enabled=true] Enabled or Disable Retry Policy functionality. + * @param {number} [options.retry.maxRetries=10] Retry failed requests X times. + * @param {object} [options.headers] Additional headers that will be added to the outgoing requests. + * @param {string} [options.proxy] Add the `superagent-proxy` dependency and specify a proxy url eg 'https://myproxy.com:1234' + * @param {boolean} [options.includeResponseHeaders] Include the response headers in the payload in the format `{ data, headers }`. + */ + constructor(options) { + if (!options || typeof options !== 'object') { + throw new ArgumentError('Management API SDK options must be an object'); + } + + if (!options.domain || options.domain.length === 0) { + throw new ArgumentError('Must provide a domain'); + } + + const baseUrl = util.format(BASE_URL_FORMAT, options.domain); + + const defaultHeaders = { + 'User-Agent': `node.js/${process.version.replace('v', '')}`, + 'Content-Type': 'application/json', + }; + + const managerOptions = { + headers: Object.assign(defaultHeaders, options.headers || {}), + baseUrl, + }; + + if (options.token === undefined) { + const config = Object.assign( + { audience: util.format(MANAGEMENT_API_AUD_FORMAT, options.domain) }, + options + ); + + if (options.tokenProvider) { + config.enableCache = options.tokenProvider.enableCache; + config.cacheTTLInSeconds = options.tokenProvider.cacheTTLInSeconds; + delete config.tokenProvider; + } + + this.tokenProvider = new ManagementTokenProvider(config); + } else if (typeof options.token !== 'string' || options.token.length === 0) { + throw new ArgumentError('Must provide a token'); + } else { + this.tokenProvider = { + getAccessToken() { + return Promise.resolve(options.token); + }, + }; + managerOptions.headers['Authorization'] = `Bearer ${options.token}`; } - this.tokenProvider = new ManagementTokenProvider(config); managerOptions.tokenProvider = this.tokenProvider; - } else if (typeof options.token !== 'string' || options.token.length === 0) { - throw new ArgumentError('Must provide a token'); - } else { - managerOptions.headers['Authorization'] = 'Bearer ' + options.token; - } - if (options.telemetry !== false) { - var telemetry = jsonToBase64(options.clientInfo || this.getClientInfo()); - managerOptions.headers['Auth0-Client'] = telemetry; + if (options.telemetry !== false) { + const clientInfo = options.clientInfo || generateClientInfo(); + if ('string' === typeof clientInfo.name && clientInfo.name.length > 0) { + const telemetry = jsonToBase64(clientInfo); + managerOptions.headers['Auth0-Client'] = telemetry; + } + } + + managerOptions.retry = options.retry; + managerOptions.includeResponseHeaders = options.includeResponseHeaders; + managerOptions.proxy = options.proxy; + + /** + * Simple abstraction for performing CRUD operations on the + * clients endpoint. + * + * @type {ClientsManager} + */ + this.clients = new ClientsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the client grants + * endpoint. + * + * @type {ClientGrantsManager} + */ + this.clientGrants = new ClientGrantsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the grants + * endpoint. + * + * @type {GrantsManager} + */ + this.grants = new GrantsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * users endpoint. + * + * @type {UsersManager} + */ + this.users = new UsersManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * user-blocks endpoint. + * + * @type {UserBlocksManager} + */ + this.userBlocks = new UserBlocksManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * guardian endpoint. + * + * @type {GuardianManager} + */ + this.guardian = new GuardianManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * custom domains endpoint. + * + * @type {CustomDomainsManager} + */ + this.customDomains = new CustomDomainsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * connections endpoint. + * + * @type {ConnectionsManager} + */ + this.connections = new ConnectionsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * device credentials endpoint. + * + * @type {DeviceCredentialsManager} + */ + this.deviceCredentials = new DeviceCredentialsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * rules endpoint. + * + * @type {RulesManager} + */ + this.rules = new RulesManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * blacklisted tokens endpoint. + * + * @type {BlacklistedTokensManager} + */ + this.blacklistedTokens = new BlacklistedTokensManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * email provider endpoint. + * + * @type {EmailProviderManager} + */ + this.emailProvider = new EmailProviderManager(managerOptions); + + /** + * ManagementClient account statistics manager. + * + * @type {StatsManager} + */ + this.stats = new StatsManager(managerOptions); + + /** + * ManagementClient tenant settings manager. + * + * @type {TenantManager} + */ + this.tenant = new TenantManager(managerOptions); + + /** + * Jobs manager. + * + * @type {JobsManager} + */ + this.jobs = new JobsManager(managerOptions); + + /** + * Tickets manager. + * + * @type {TicketsManager} + */ + this.tickets = new TicketsManager(managerOptions); + + /** + * Logs manager. + * + * @type {LogsManager} + */ + this.logs = new LogsManager(managerOptions); + + /** + * Log Streams manager. + * + * @type {LogStreamsManager} + */ + this.logStreams = new LogStreamsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * resource servers endpoint. + * + * @type {ResourceServersManager} + */ + this.resourceServers = new ResourceServersManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on + * Auth0's Email Templates + * + * @type {EmailTemplatesManager} + */ + this.emailTemplates = new EmailTemplatesManager(managerOptions); + + /** + * RulesConfigs manager. + * + * @type {RulesConfigsManager} + */ + this.rulesConfigs = new RulesConfigsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * roles endpoint. + * + * @type {RolesManager} + */ + this.roles = new RolesManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * hooks endpoint. + * + * @type {HooksManager} + */ + this.hooks = new HooksManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * branding endpoint. + * + * @type {BrandingManager} + */ + this.branding = new BrandingManager(managerOptions); + + /** + * ManagementClient migrations manager. + * + * @type {MigrationsManager} + */ + this.migrations = new MigrationsManager(managerOptions); + + /** + * Prompts Manager + * + * @type {PromptsManager} + */ + this.prompts = new PromptsManager(managerOptions); + + /** + * Simple abstraction for performing CRUD operations on the + * actions endpoint. + * + * @type {ActionsManager} + */ + this.actions = new ActionsManager(managerOptions); + + /** + * Organizations Manager + * + * @type {OrganizationsManager} + */ + this.organizations = new OrganizationsManager(managerOptions); + + /** + * Attack Protection Manager + * + * @type {AttackProtectionManager} + */ + this.attackProtection = new AttackProtectionManager(managerOptions); } - managerOptions.retry = options.retry; + /** + * Get all connections. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getConnections(params, function (err, connections) { + * console.log(connections.length); + * }); + * @param {object} [params] Connections params. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getConnections(...args) { + return this.connections.getAll(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * clients endpoint. + * Create a new connection. * - * @type {ClientsManager} + * @example + * management.createConnection(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Connection created. + * }); + * @param {object} data Connection data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.clients = new ClientsManager(managerOptions); + + createConnection(...args) { + return this.connections.create(...args); + } /** - * Simple abstraction for performing CRUD operations on the client grants - * endpoint. + * Get an Auth0 connection. + * + * @example + * management.getConnection({ id: CONNECTION_ID }, function (err, connection) { + * if (err) { + * // Handle error. + * } * - * @type {ClientGrantsManager} + * console.log(connection); + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.clientGrants = new ClientGrantsManager(managerOptions); + getConnection(...args) { + return this.connections.get(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * users endpoint. + * Delete an existing connection. + * + * @example + * management.deleteConnection({ id: CONNECTION_ID }, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {UsersManager} + * // Connection deleted. + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.users = new UsersManager(managerOptions); + deleteConnection(...args) { + return this.connections.delete(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * guardian endpoint. + * Update an existing connection. + * + * @example + * var data = { name: 'newConnectionName' }; + * var params = { id: CONNECTION_ID }; * - * @type {GuardianManager} + * management.updateConnection(params, data, function (err, connection) { + * if (err) { + * // Handle error. + * } + * + * console.log(connection.name); // 'newConnectionName' + * }); + * @param {object} params Connection parameters. + * @param {string} params.id Connection ID. + * @param {object} data Updated connection data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.guardian = new GuardianManager(managerOptions); + updateConnection(...args) { + return this.connections.update(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * custom domains endpoint. + * Get all Auth0 clients. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; * - * @type {CustomDomainsManager} + * management.getClients(params, function (err, clients) { + * console.log(clients.length); + * }); + * @param {object} [params] Clients parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.customDomains = new CustomDomainsManager(managerOptions); + getClients(...args) { + return this.clients.getAll(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * connections endpoint. + * Get an Auth0 client. + * + * @example + * management.getClient({ client_id: CLIENT_ID }, function (err, client) { + * if (err) { + * // Handle error. + * } * - * @type {ConnectionsManager} + * console.log(client); + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {string} params.fields Comma-separated list of fields to include or exclude (based on value provided for include_fields). + * @param {string} params.include_fields Whether specified fields are to be included (true) or excluded (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.connections = new ConnectionsManager(managerOptions); + getClient(...args) { + return this.clients.get(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * device credentials endpoint. + * Create an Auth0 client. + * + * @example + * management.createClient(data, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {DeviceCredentialsManager} + * // Client created. + * }); + * @param {object} data The client data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.deviceCredentials = new DeviceCredentialsManager(managerOptions); + createClient(...args) { + return this.clients.create(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * rules endpoint. + * Update an Auth0 client. + * + * @example + * var data = { name: 'newClientName' }; + * var params = { client_id: CLIENT_ID }; * - * @type {RulesManager} + * management.updateClient(params, data, function (err, client) { + * if (err) { + * // Handle error. + * } + * + * console.log(client.name); // 'newClientName' + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {object} data Updated client data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.rules = new RulesManager(managerOptions); + updateClient(...args) { + return this.clients.update(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * blacklisted tokens endpoint. + * Delete an Auth0 client. * - * @type {BlacklistedtokensManager} + * @example + * management.deleteClient({ client_id: CLIENT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Client deleted. + * }); + * @param {object} params Client parameters. + * @param {string} params.client_id Application client ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.blacklistedTokens = new BlacklistedTokensManager(managerOptions); + deleteClient(...args) { + return this.clients.delete(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * email provider endpoint. + * Get all Auth0 Client Grants. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; * - * @type {EmailProviderManager} + * management.getClientGrants(params, function (err, grants) { + * console.log(grants.length); + * }); + * @param {object} [params] Client Grants parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.emailProvider = new EmailProviderManager(managerOptions); + getClientGrants(...args) { + return this.clientGrants.getAll(...args); + } /** - * ManagementClient account statistics manager. + * Create an Auth0 client grant. + * + * @example + * management.clientGrants.create(data, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {StatsManager} + * // Client grant created. + * }); + * @param {object} data The client data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.stats = new StatsManager(managerOptions); + createClientGrant(...args) { + return this.clientGrants.create(...args); + } /** - * ManagementClient tenant settings manager. + * Update an Auth0 client grant. + * + * @example + * var data = { + * client_id: CLIENT_ID, + * audience: AUDIENCE, + * scope: [] + * }; + * var params = { id: CLIENT_GRANT_ID }; * - * @type {TenantManager} + * management.clientGrants.update(params, data, function (err, grant) { + * if (err) { + * // Handle error. + * } + * + * console.log(grant.id); + * }); + * @param {object} params Client parameters. + * @param {string} params.id Client grant ID. + * @param {object} data Updated client data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.tenant = new TenantManager(managerOptions); + updateClientGrant(...args) { + return this.clientGrants.update(...args); + } /** - * Jobs manager. + * Delete an Auth0 client grant. * - * @type {JobsManager} + * @example + * management.clientGrants.delete({ id: GRANT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Grant deleted. + * }); + * @param {object} params Client parameters. + * @param {string} params.id Client grant ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.jobs = new JobsManager(managerOptions); + deleteClientGrant(...args) { + return this.clientGrants.delete(...args); + } /** - * Tickets manager. + * Get all Auth0 Grants. * - * @type {TicketsManager} + * @example + * var params = { + * per_page: 10, + * page: 0, + * include_totals: true, + * user_id: USER_ID, + * client_id: CLIENT_ID, + * audience: AUDIENCE + * }; + * + * management.getGrants(params, function (err, grants) { + * console.log(grants.length); + * }); + * @param {object} params Grants parameters. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {string} params.user_id The user_id of the grants to retrieve. + * @param {string} params.client_id The client_id of the grants to retrieve. + * @param {string} params.audience The audience of the grants to retrieve. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.tickets = new TicketsManager(managerOptions); + getGrants(...args) { + return this.grants.getAll(...args); + } /** - * Logs manager. + * Delete an Auth0 grant. + * + * @example + * var params = { + * id: GRANT_ID, + * user_id: USER_ID + * }; + * + * management.deleteGrant(params, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {LogsManager} + * // Grant deleted. + * }); + * @param {object} params Grant parameters. + * @param {string} params.id Grant ID. + * @param {string} params.user_id The user_id of the grants to delete. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.logs = new LogsManager(managerOptions); + deleteGrant(...args) { + return this.grants.delete(...args); + } /** - * Simple abstraction for performing CRUD operations on the - * resource servers endpoint. + * Create an Auth0 credential. + * + * @example + * management.createConnection(data, function (err) { + * if (err) { + * // Handle error. + * } * - * @type {ResourceServersManager} + * // Credential created. + * }); + * @param {object} data The device credential data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.resourceServers = new ResourceServersManager(managerOptions); + createDevicePublicKey(...args) { + return this.deviceCredentials.createPublicKey(...args); + } /** - * Simple abstraction for performing CRUD operations on - * Auth0's Email Templates + * Get all Auth0 credentials. + * + * @example + * var params = {user_id: "USER_ID"}; * - * @type {EmailTemplatesManager} + * management.getDeviceCredentials(params, function (err, credentials) { + * console.log(credentials.length); + * }); + * @param {object} params Credential parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.emailTemplates = new EmailTemplatesManager(managerOptions); + getDeviceCredentials(...args) { + return this.deviceCredentials.getAll(...args); + } /** - * RulesConfigs manager. + * Delete an Auth0 device credential. + * + * @example + * var params = { id: CREDENTIAL_ID }; * - * @type {RulesConfigsManager} + * management.deleteDeviceCredential(params, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Credential deleted. + * }); + * @param {object} params Credential parameters. + * @param {string} params.id Device credential ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} */ - this.rulesConfigs = new RulesConfigsManager(managerOptions); -}; + deleteDeviceCredential(...args) { + return this.deviceCredentials.delete(...args); + } -/** - * Return an object with information about the current client, - * - * @method getClientInfo - * @memberOf module:management.ManagementClient.prototype - * - * @return {Object} Object containing client information. - */ -ManagementClient.prototype.getClientInfo = function() { - var clientInfo = { - name: 'node-auth0', - version: pkg.version, - dependencies: [], - environment: [ - { - name: 'node.js', - version: process.version.replace('v', '') - } - ] - }; - // Add the dependencies to the client info object. - Object.keys(pkg.dependencies).forEach(function(name) { - clientInfo.dependencies.push({ - name: name, - version: pkg.dependencies[name] - }); - }); - - return clientInfo; -}; + /** + * Get all rules. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getRules(params, function (err, rules) { + * console.log(rules.length); + * }); + * @param {object} [params] Rules parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRules(...args) { + return this.rules.getAll(...args); + } -/** - * Get all connections. - * - * @method getConnections - * @memberOf module:management.ManagementClient.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getConnections(params, function (err, connections) { - * console.log(connections.length); - * }); - * - * @param {Object} [params] Connections params. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getConnections', 'connections.getAll'); + /** + * Create a new rule. + * + * @example + * management.createRule(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Rule created. + * }); + * @param {object} data Rule data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createRule(...args) { + return this.rules.create(...args); + } -/** - * Create a new connection. - * - * @method createConnection - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createConnection(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Conection created. - * }); - * - * @param {Object} data Connection data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createConnection', 'connections.create'); + /** + * Get an Auth0 rule. + * + * @example + * management.getRule({ id: RULE_ID }, function (err, rule) { + * if (err) { + * // Handle error. + * } + * + * console.log(rule); + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRule(...args) { + return this.rules.get(...args); + } -/** - * Get an Auth0 connection. - * - * @method getConnection - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getConnection({ id: CONNECTION_ID }, function (err, connection) { - * if (err) { - * // Handle error. - * } - * - * console.log(connection); - * }); - * - * @param {Object} params Connection parameters. - * @param {String} params.id Connection ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getConnection', 'connections.get'); + /** + * Delete an existing rule. + * + * @example + * auth0.deleteRule({ id: RULE_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Rule deleted. + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteRule(...args) { + return this.rules.delete(...args); + } -/** - * Delete an existing connection. - * - * @method deleteConnection - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteConnection({ id: CONNECTION_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Conection deleted. - * }); - * - * @param {Object} params Connection parameters. - * @param {String} params.id Connection ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteConnection', 'connections.delete'); + /** + * Update an existing rule. + * + * @example + * var params = { id: RULE_ID }; + * var data = { name: 'my-rule'}; + * management.updateRule(params, data, function (err, rule) { + * if (err) { + * // Handle error. + * } + * + * console.log(rule.name); // 'my-rule'. + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {object} data Updated rule data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateRule(...args) { + return this.rules.update(...args); + } -/** - * Update an existing connection. - * - * @method updateConnection - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var data = { name: 'newConnectionName' }; - * var params = { id: CONNECTION_ID }; - * - * management.updateConnection(params, data, function (err, connection) { - * if (err) { - * // Handle error. - * } - * - * console.log(connection.name); // 'newConnectionName' - * }); - * - * @param {Object} params Connection parameters. - * @param {String} params.id Connection ID. - * @param {Object} data Updated connection data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateConnection', 'connections.update'); + /** + * Get all users. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * search_engine: 'v3', + * q: 'name:*jane*', + * per_page: 10, + * page: 0 + * }; + * + * auth0.getUsers(params, function (err, users) { + * console.log(users.length); + * }); + * @param {object} [params] Users params. + * @param {number} [params.search_engine] The version of the search engine to use. + * @param {string} [params.q] User Search string to filter which users are returned. Follows Lucene query string syntax as documented at https://auth0.com/docs/api/management/v2#!/Users/get_users. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUsers(...args) { + return this.users.getAll(...args); + } -/** - * Get all Auth0 clients. - * - * @method getClients - * @memberOf module:management.ManagementClient.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getClients(params, function (err, clients) { - * console.log(clients.length); - * }); - * - * @param {Object} [params] Clients parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getClients', 'clients.getAll'); + /** + * Get users for a given email address + * + * @example + * This method takes an email address as the first argument, + * and returns all users with that email address + * + * + * auth0.getUsersByEmail(email, function (err, users) { + * console.log(users); + * }); + * @param {string} [email] Email address of user(s) to find + * @param {object} [options] Additional options to pass to the endpoint + * @param {string} [options.fields] Comma-separated list of fields to include or exclude in the result + * @param {boolean} [options.include_fields] Whether specified fields are to be included (true) or excluded (false). Defaults to true. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUsersByEmail(...args) { + return this.users.getByEmail(...args); + } -/** - * Get an Auth0 client. - * - * @method getClient - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getClient({ client_id: CLIENT_ID }, function (err, client) { - * if (err) { - * // Handle error. - * } - * - * console.log(client); - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getClient', 'clients.get'); + /** + * Get a user by its id. + * + * @example + * management.getUser({ id: USER_ID }, function (err, user) { + * console.log(user); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUser(...args) { + return this.users.get(...args); + } -/** - * Create an Auth0 client. - * - * @method createClient - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createClient(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client created. - * }); - * - * @param {Object} data The client data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createClient', 'clients.create'); + /** + * Delete all users. + * + * @example + * management.deleteAllUsers(function (err) { + * if (err) { + * // Handle error. + * } + * + * // Users deleted + * }); + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + * @deprecated This method will be removed in the next major release. + */ + deleteAllUsers(...args) { + return this.users.deleteAll(...args); + } -/** - * Update an Auth0 client. - * - * @method updateClient - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var data = { name: 'newClientName' }; - * var params = { client_id: CLIENT_ID }; - * - * management.updateClient(params, data, function (err, client) { - * if (err) { - * // Handle error. - * } - * - * console.log(client.name); // 'newClientName' - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Object} data Updated client data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateClient', 'clients.update'); + /** + * Delete a user by its id. + * + * @example + * management.deleteUser({ id: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User deleted. + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + deleteUser(...args) { + return this.users.delete(...args); + } -/** - * Delete an Auth0 client. - * - * @method deleteClient - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteClient({ client_id: CLIENT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client deleted. - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.client_id Application client ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteClient', 'clients.delete'); + /** + * Create a new user. + * + * @example + * management.createUser(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User created. + * }); + * @param {object} data User data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createUser(...args) { + return this.users.create(...args); + } -/** - * Get all Auth0 Client Grants. - * - * @method getAll - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getClientGrants(params, function (err, grants) { - * console.log(grants.length); - * }); - * - * @param {Object} [params] Client Grants parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getClientGrants', 'clientGrants.getAll'); + /** + * Update a user by its id. + * + * @example + * var params = { id: USER_ID }; + * + * management.updateUser(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user parameters. + * @param {string} params.id The user id. + * @param {object} data New user data. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateUser(...args) { + return this.users.update(...args); + } -/** - * Create an Auth0 client grant. - * - * @method create - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * management.clientGrants.create(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Client grant created. - * }); - * - * @param {Object} data The client data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createClientGrant', 'clientGrants.create'); + /** + * Update the user metadata for a user. + * + * @example + * var params = { id: USER_ID }; + * var metadata = { + * address: '123th Node.js Street' + * }; + * + * management.updateUserMetadata(params, metadata, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {object} metadata New user metadata. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateUserMetadata(...args) { + return this.users.updateUserMetadata(...args); + } -/** - * Update an Auth0 client grant. - * - * @method update - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * var data = { - * client_id: CLIENT_ID, - * audience: AUDIENCE, - * scope: [] - * }; - * var params = { id: CLIENT_GRANT_ID }; - * - * management.clientGrants.update(params, data, function (err, grant) { - * if (err) { - * // Handle error. - * } - * - * console.log(grant.id); - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.id Client grant ID. - * @param {Object} data Updated client data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateClientGrant', 'clientGrants.update'); + /** + * Update the app metadata for a user. + * + * @example + * var params = { id: USER_ID }; + * var metadata = { + * foo: 'bar' + * }; + * + * management.updateAppMetadata(params, metadata, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Updated user. + * console.log(user); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {object} metadata New app metadata. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateAppMetadata(...args) { + return this.users.updateAppMetadata(...args); + } -/** - * Delete an Auth0 client grant. - * - * @method delete - * @memberOf module:management.ClientGrantsManager.prototype - * - * @example - * management.clientGrants.delete({ id: GRANT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Grant deleted. - * }); - * - * @param {Object} params Client parameters. - * @param {String} params.id Client grant ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteClientGrant', 'clientGrants.delete'); + /** + * Delete a multifactor provider for a user. + * + * @example + * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; + * + * management.deleteUserMultifactor(params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users accounts unlinked. + * }); + * @param {object} params Data object. + * @param {string} params.id The user id. + * @param {string} params.provider Multifactor provider. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + deleteUserMultifactor(...args) { + return this.users.deleteMultifactorProvider(...args); + } -/** - * Create an Auth0 credential. - * - * @method createDevicePublicKey - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createConnection(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Credential created. - * }); - * - * @param {Object} data The device credential data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'createDevicePublicKey', - 'deviceCredentials.createPublicKey' -); + /** + * Delete a multifactor provider for a user. + * + * @example + * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; + * + * management.deleteUserMultifcator(params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users accounts unlinked. + * }); + * @param {object} params Data object. + * @param {string} params.id The user id. + * @param {string} params.provider Multifactor provider. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + * @deprecated The function name has a typo. + * We're shipping this so it doesn't break compatibility. + * Use {@link deleteUserMultifactor} instead. + */ + deleteUserMultifcator(...args) { + return this.users.deleteMultifactorProvider(...args); + } -/** - * Get all Auth0 credentials. - * - * @method getDeviceCredentials - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getDeviceCredentials(function (err, credentials) { - * console.log(credentials.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getDeviceCredentials', 'deviceCredentials.getAll'); + /** + * Unlink the given accounts. + * + * @example + * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID }; + * + * management.unlinkUsers(params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users accounts unlinked. + * }); + * @param {object} params Linked users data. + * @param {string} params.id Primary user ID. + * @param {string} params.provider Identity provider in use. + * @param {string} params.user_id Secondary user ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + unlinkUsers(...args) { + return this.users.unlink(...args); + } -/** - * Delete an Auth0 device credential. - * - * @method deleteDeviceCredential - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: CREDENTIAL_ID }; - * - * management.deleteDeviceCredential(params, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Credential deleted. - * }); - * - * @param {Object} params Credential parameters. - * @param {String} params.id Device credential ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteDeviceCredential', 'deviceCredentials.delete'); + /** + * Link the user with another account. + * + * @example + * var userId = 'USER_ID'; + * var params = { + * user_id: 'OTHER_USER_ID', + * connection_id: 'CONNECTION_ID' + * }; + * + * management.linkUsers(userId, params, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // Users linked. + * }); + * @param {string} userId ID of the primary user. + * @param {object} params Secondary user data. + * @param {string} params.user_id ID of the user to be linked. + * @param {string} params.connection_id ID of the connection to be used. + * @param {string} params.provider Identity provider of the secondary user account being linked. + * @param {string} params.link_with JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + linkUsers(...args) { + return this.users.link(...args); + } -/** - * Get all rules. - * - * @method getRules - * @memberOf module:management.ManagementClient.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getRules(params, function (err, rules) { - * console.log(rules.length); - * }); - * - * @param {Object} [params] Rules parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getRules', 'rules.getAll'); + /** + * Get user's log events. + * + * @example + * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; + * + * management.getUserLogs(params, function (err, logs) { + * if (err) { + * // Handle error. + * } + * + * console.log(logs); + * }); + * @param {object} params Get logs data. + * @param {string} params.id User id. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUserLogs(...args) { + return this.users.logs(...args); + } -/** - * Create a new rule. - * - * @method createRule - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createRule(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rule created. - * }); - * - * @param {Object} data Rule data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createRule', 'rules.create'); + /** + * Get user's roles + * + * @example + * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; + * + * management.getUserRoles(params, function (err, logs) { + * if (err) { + * // Handle error. + * } + * + * console.log(logs); + * }); + * @param {object} params Get roles data. + * @param {string} params.id User id. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUserRoles(...args) { + return this.users.getRoles(...args); + } -/** - * Get an Auth0 rule. - * - * @method getRule - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getRule({ id: RULE_ID }, function (err, rule) { - * if (err) { - * // Handle error. - * } - * - * console.log(rule); - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getRule', 'rules.get'); + /** + * Assign roles to a user + * + * @example + * var parms = { id : 'USER_ID'}; + * var data = { "roles" :["role1"]}; + * + * management.assignRolestoUser(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User assigned roles. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {object} data data object containing list of role IDs + * @param {string} data.roles Array of role IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + assignRolestoUser(...args) { + return this.users.assignRoles(...args); + } + + /** + * Assign users to a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "users" : ["userId1","userId2"]}; + * + * management.roles.assignUsers(params, data, function (err, user) { + * if (err) { + * // Handle error. + * } + * + * // permissions added. + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + assignUsersToRole(...args) { + return this.roles.assignUsers(...args); + } + + /** + * Remove roles from a user + * + * @example + * var parms = { id : 'USER_ID'}; + * var data = { "roles" :["role1"]}; + * + * management.removeRolesFromUser(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User assigned roles. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of role IDs + * @param {string} data.roles Array of role IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removeRolesFromUser(...args) { + return this.users.removeRoles(...args); + } + + /** + * Get user's permissions + * + * @example + * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; + * + * management.getUserPermissions(params, function (err, logs) { + * if (err) { + * // Handle error. + * } + * + * console.log(logs); + * }); + * @param {object} params Get permissions data. + * @param {string} params.id User id. + * @param {number} params.per_page Number of results per page. + * @param {number} params.page Page number, zero indexed. + * @param {string} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. + * @param {boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUserPermissions(...args) { + return this.users.getPermissions(...args); + } + + /** + * Assign permissions to a user + * + * @example + * var parms = { id : 'USER_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.assignPermissionsToUser(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User assigned permissions. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of permissions + * @param {string} data.permissions Array of permission IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + assignPermissionsToUser(...args) { + return this.users.assignPermissions(...args); + } + + /** + * Remove permissions from a user + * + * @example + * var parms = { id : 'USER_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.removePermissionsFromUser(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User assigned permissions. + * }); + * @param {object} params params object + * @param {string} params.id user_id + * @param {string} data data object containing list of permission IDs + * @param {string} data.permissions Array of permission IDs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removePermissionsFromUser(...args) { + return this.users.removePermissions(...args); + } + + /** + * Get a list of a user's Guardian enrollments. + * + * @example + * management.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) { + * console.log(enrollments); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianEnrollments(...args) { + return this.users.getGuardianEnrollments(...args); + } + + /** + * Generate new Guardian recovery code. + * + * @example + * management.regenerateRecoveryCode({ id: USER_ID }, function (err, newRecoveryCode) { + * console.log(newRecoveryCode); + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + regenerateRecoveryCode(...args) { + return this.users.regenerateRecoveryCode(...args); + } + + /** + * Invalidate all remembered browsers for MFA. + * + * @example + * management.invalidateRememberBrowser({ id: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Invalidated all remembered browsers. + * }); + * @param {object} data The user data object. + * @param {string} data.id The user id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + invalidateRememberBrowser(...args) { + return this.users.invalidateRememberBrowser(...args); + } + + /** + * Get user blocks by its id. + * + * @example + * management.getUserBlocks({ id: USER_ID }, function (err, blocks) { + * if (err) { + * // Handle error. + * } + * + * console.log(blocks); + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + getUserBlocks(...args) { + return this.userBlocks.get(...args); + } + + /** + * Unblock an user by its id. + * + * @example + * management.unblockUser({ id: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User unblocked. + * }); + * @param {object} params The user data object.. + * @param {string} params.id The user id. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + unblockUser(...args) { + return this.userBlocks.delete(...args); + } + + /** + * Get user blocks by its identifier. + * + * @example + * management.getUserBlocksByIdentifier({ identifier: USER_ID }, function (err, blocks) { + * if (err) { + * // Handle error. + * } + * + * console.log(blocks); + * }); + * @param {object} params The user data object.. + * @param {string} params.identifier The user identifier, any of: username, phone_number, email. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + getUserBlocksByIdentifier(...args) { + return this.userBlocks.getByIdentifier(...args); + } + + /** + * Unblock an user by its id. + * + * @example + * management.unblockUserByIdentifier({ identifier: USER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // User unblocked. + * }); + * @param {object} params The user data object.. + * @param {string} params.identifier The user identifier, any of: username, phone_number, email. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + unblockUserByIdentifier(...args) { + return this.userBlocks.deleteByIdentifier(...args); + } + + /** + * Get a single Guardian enrollment. + * + * @example + * management.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) { + * console.log(enrollment); + * }); + * @param {object} data The Guardian enrollment data object. + * @param {string} data.id The Guardian enrollment id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianEnrollment(...args) { + return this.guardian.getGuardianEnrollment(...args); + } + + /** + * Delete a user's Guardian enrollment. + * + * @example + * management.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email provider deleted. + * }); + * @param {object} data The Guardian enrollment data object. + * @param {string} data.id The Guardian enrollment id. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteGuardianEnrollment(...args) { + return this.guardian.deleteGuardianEnrollment(...args); + } + + /** + * Get all blacklisted tokens. + * + * @example + * management.getBlacklistedTokens(function (err, tokens) { + * console.log(tokens.length); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getBlacklistedTokens(...args) { + return this.blacklistedTokens.getAll(...args); + } + + /** + * Blacklist a new token. + * + * @example + * var token = { + * aud: 'aud', + * jti: 'jti' + * }; + * + * management.blacklistToken(token, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Token blacklisted. + * }); + * @param {object} token Token data. + * @param {string} token.aud Audience (your app client ID). + * @param {string} token.jti The JWT ID claim. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + blacklistToken(...args) { + return this.blacklistedTokens.add(...args); + } + + /** + * Create a new Email Template. + * + * @example + * management.createEmailTemplate(data, function (err) { + * if (err) { + * // Handle error. + * // Email Template created. + * }); + * @param {object} data Email Template data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createEmailTemplate(...args) { + return this.emailTemplates.create(...args); + } + + /** + * Get an Auth0 Email Template. + * + * @example + * management.getEmailTemplate({ name: EMAIL_TEMPLATE_NAME }, function (err, emailTemplate) { + * if (err) { + * // Handle error. + * } + * + * console.log(emailTemplate); + * }); + * @param {object} params Email Template parameters. + * @param {string} params.name Template Name + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getEmailTemplate(...args) { + return this.emailTemplates.get(...args); + } + + /** + * Update an existing Email Template. + * + * @example + * var data = { from: 'new@email.com' }; + * var params = { name: EMAIL_TEMPLATE_NAME }; + * + * management.updateEmailTemplates(params, data, function (err, emailTemplate) { + * if (err) { + * // Handle error. + * } + * + * console.log(emailTemplate.from); // 'new@email.com' + * }); + * @param {object} params Email Template parameters. + * @param {string} params.name Template Name + * @param {object} data Updated Email Template data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateEmailTemplate(...args) { + return this.emailTemplates.update(...args); + } + + /** + * Get the email provider. + * + * @example + * management.getEmailProvider(function (err, provider) { + * console.log(provider.length); + * }); + * @param {Function} [cb] Callback function. + * @param {object} [params] Clients parameters. + * @param {number} [params.fields] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve: name, enabled, settings fields. + * @param {number} [params.include_fields] true if the fields specified are to be excluded from the result, false otherwise (defaults to true) + * @returns {Promise|undefined} + */ + getEmailProvider(...args) { + return this.emailProvider.get(...args); + } + + /** + * Configure the email provider. + * + * @example + * management.configureEmailProvider(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email provider configured. + * }); + * @param {object} data The email provider data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + configureEmailProvider(...args) { + return this.emailProvider.configure(...args); + } + + /** + * Delete email provider. + * + * @example + * management.deleteEmailProvider(function (err) { + * if (err) { + * // Handle error. + * } + * + * // Email provider deleted. + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteEmailProvider(...args) { + return this.emailProvider.delete(...args); + } + + /** + * Update the email provider. + * + * @example + * management.updateEmailProvider(params, data, function (err, provider) { + * if (err) { + * // Handle error. + * } + * + * // Updated email provider. + * console.log(provider); + * }); + * @param {object} params Email provider parameters. + * @param {object} data Updated email provider data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateEmailProvider(...args) { + return this.emailProvider.update(...args); + } + + /** + * Get a the active users count. + * + * @example + * management.getActiveUsersCount(function (err, usersCount) { + * if (err) { + * // Handle error. + * } + * + * console.log(usersCount); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getActiveUsersCount(...args) { + return this.stats.getActiveUsersCount(...args); + } + + /** + * Get the daily stats. + * + * @example + * var params = { + * from: '{YYYYMMDD}', // First day included in the stats. + * to: '{YYYYMMDD}' // Last day included in the stats. + * }; + * + * management.getDaily(params, function (err, stats) { + * if (err) { + * // Handle error. + * } + * + * console.log(stats); + * }); + * @param {object} params Stats parameters. + * @param {string} params.from The first day in YYYYMMDD format. + * @param {string} params.to The last day in YYYYMMDD format. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getDailyStats(...args) { + return this.stats.getDaily(...args); + } + + /** + * Get the tenant settings.. + * + * @example + * management.getSettings(function (err, settings) { + * if (err) { + * // Handle error. + * } + * + * console.log(settings); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getTenantSettings(...args) { + return this.tenant.getSettings(...args); + } + + /** + * Update the tenant settings. + * + * @example + * management.updateTenantSettings(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data The new tenant settings. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateTenantSettings(...args) { + return this.tenant.updateSettings(...args); + } + + /** + * Get a job by its ID. + * + * @example + * var params = { + * id: '{JOB_ID}' + * }; + * + * management.getJob(params, function (err, job) { + * if (err) { + * // Handle error. + * } + * + * // Retrieved job. + * console.log(job); + * }); + * @param {object} params Job parameters. + * @param {string} params.id Job ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getJob(...args) { + return this.jobs.get(...args); + } + + /** + * Given a path to a file and a connection id, create a new job that imports the + * users contained in the file or JSON string and associate them with the given + * connection. + * + * @example + * var params = { + * connection_id: '{CONNECTION_ID}', + * users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}' + * }; + * + * management.importUsers(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data Users import data. + * @param {string} data.connection_id connection_id of the connection to which users will be imported. + * @param {string} [data.users] Path to the users data file. Either users or users_json is mandatory. + * @param {string} [data.users_json] JSON data for the users. + * @param {boolean} [data.upsert] Whether to update users if they already exist (true) or to ignore them (false). + * @param {boolean} [data.send_completion_email] Whether to send a completion email to all tenant owners when the job is finished (true) or not (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + importUsers(...args) { + return this.jobs.importUsers(...args); + } + + /** + * Given a path to a file and a connection id, create a new job that imports the + * users contained in the file or JSON string and associate them with the given + * connection. + * + * @example + * var params = { + * connection_id: '{CONNECTION_ID}', + * users: '{PATH_TO_USERS_FILE}' // or users_json: '{USERS_JSON_STRING}' + * }; + * + * management.importUsersJob(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data Users import data. + * @param {string} data.connection_id connection_id of the connection to which users will be imported. + * @param {string} [data.users] Path to the users data file. Either users or users_json is mandatory. + * @param {string} [data.users_json] JSON data for the users. + * @param {boolean} [data.upsert] Whether to update users if they already exist (true) or to ignore them (false). + * @param {boolean} [data.send_completion_email] Whether to send a completion email to all tenant owners when the job is finished (true) or not (false). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + importUsersJob(...args) { + return this.jobs.importUsersJob(...args); + } + + /** + * Export all users to a file using a long running job. + * + * @example + * var data = { + * connection_id: 'con_0000000000000001', + * format: 'csv', + * limit: 5, + * fields: [ + * { + * "name": "user_id" + * }, + * { + * "name": "name" + * }, + * { + * "name": "email" + * }, + * { + * "name": "identities[0].connection", + * "export_as": "provider" + * }, + * { + * "name": "user_metadata.some_field" + * } + * ] + * } + * + * management.exportUsers(data, function (err, results) { + * if (err) { + * // Handle error. + * } + * + * // Retrieved job. + * console.log(results); + * }); + * @param {object} data Users export data. + * @param {string} [data.connection_id] The connection id of the connection from which users will be exported + * @param {string} [data.format] The format of the file. Valid values are: "json" and "csv". + * @param {number} [data.limit] Limit the number of records. + * @param {object[]} [data.fields] A list of fields to be included in the CSV. If omitted, a set of predefined fields will be exported. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + exportUsers(...args) { + return this.jobs.exportUsers(...args); + } + + /** + * Given a job ID, retrieve the failed/errored items + * + * @example + * var params = { + * id: '{JOB_ID}' + * }; + * + * management.jobs.errors(params, function (err, job) { + * if (err) { + * // Handle error. + * } + * + * // Retrieved job. + * console.log(job); + * }); + * @param {object} params Job parameters. + * @param {string} params.id Job ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getJobErrors(...args) { + return this.jobs.errors(...args); + } + + /** + * Send a verification email to a user. + * + * @example + * var params = { + * user_id: '{USER_ID}' + * }; + * + * management.sendEmailVerification(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data User data object. + * @param {string} data.user_id ID of the user to be verified. + * @param {string} [data.organization_id] Organization ID + * @param {string} [data.client_id] client_id of the client (application). If no value provided, the global Client ID will be used. + * @param {object} [data.identity] Used to verify secondary, federated, and passwordless-email identities. + * @param {string} data.identity.user_id user_id of the identity. + * @param {string} data.identity.provider provider of the identity. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + sendEmailVerification(...args) { + return this.jobs.verifyEmail(...args); + } + + /** + * Create a new password change ticket. + * + * @example + * + * var params = { + * result_url: '{REDIRECT_URL}', // Redirect after using the ticket. + * user_id: '{USER_ID}' + * }; + * + * // or + * + * var params = { + * result_url: '{REDIRECT_URL}', // Redirect after using the ticket. + * email: '{USER_EMAIL}', + * connection_id: '{CONNECTION}' // eg. con_00000000001 + * }; + * + * auth0.createPasswordChangeTicket(params, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise} + */ + createPasswordChangeTicket(...args) { + return this.tickets.changePassword(...args); + } + + /** + * Create an email verification ticket. + * + * @example + * var data = { + * user_id: '{USER_ID}', + * result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used. + * }; + * + * auth0.createEmailVerificationTicket(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise} + */ + createEmailVerificationTicket(...args) { + return this.tickets.verifyEmail(...args); + } + + /** + * Get an Auth0 log. + * + * @example + * management.getLog({ id: EVENT_ID }, function (err, log) { + * if (err) { + * // Handle error. + * } + * + * console.log(log); + * }); + * @param {object} params Log parameters. + * @param {string} params.id Event ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getLog(...args) { + return this.logs.get(...args); + } + + /** + * Get all logs. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings and the search query. If pagination options are + * not present, the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 2 + * }; + * + * management.getLogs(params, function (err, logs) { + * console.log(logs.length); + * }); + * @param {object} [params] Logs params. + * @param {string} [params.q] Search Criteria using Query String Syntax + * @param {number} [params.page] Page number. Zero based + * @param {number} [params.per_page] The amount of entries per page + * @param {string} [params.sort] The field to use for sorting. + * @param {string} [params.fields] A comma separated list of fields to include or exclude + * @param {boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise. + * @param {boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getLogs(...args) { + return this.logs.getAll(...args); + } + + /** + * Get all Log Streams. + * + * + * + * management.getLogStreams( function (err, logStreams) { + * console.log(logStreams.length); + * }); + * + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getLogStreams(...args) { + return this.logStreams.getAll(...args); + } -/** - * Delete an existing rule. - * - * @method deleteRule - * @memberOf module:management.ManagementClient.prototype - * - * @example - * auth0.deleteRule({ id: RULE_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rule deleted. - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteRule', 'rules.delete'); + /** + * Create a new Log Stream. + * + * @example + * management.createLogStream(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Log Stream created. + * }); + * @param {object} data Log Stream data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createLogStream(...args) { + return this.logStreams.create(...args); + } -/** - * Update an existing rule. - * - * @method updateRule - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: RULE_ID }; - * var data = { name: 'my-rule'}; - * management.updateRule(params, data, function (err, rule) { - * if (err) { - * // Handle error. - * } - * - * console.log(rule.name); // 'my-rule'. - * }); - * - * @param {Object} params Rule parameters. - * @param {String} params.id Rule ID. - * @param {Object} data Updated rule data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateRule', 'rules.update'); + /** + * Get an Auth0 Log Stream. + * + * @example + * management.getLogStream({ id: LOG_STREAM_ID }, function (err, logStream) { + * if (err) { + * // Handle error. + * } + * + * console.log(logStream); + * }); + * @param {object} params Log Stream parameters. + * @param {string} params.id Log Stream ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getLogStream(...args) { + return this.logStreams.get(...args); + } -/** - * Get all users. - * - * @method getUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * search_engine: 'v3', - * per_page: 10, - * page: 0 - * }; - * - * auth0.getUsers(params, function (err, users) { - * console.log(users.length); - * }); - * - * @param {Object} [params] Users params. - * @param {Number} [params.search_engine] The version of the search engine to use. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getUsers', 'users.getAll'); + /** + * Delete an existing Log Stream. + * + * @example + * management.deleteLogStream({ id: LOG_STREAM_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Log Stream deleted. + * }); + * @param {object} params Log Stream parameters. + * @param {string} params.id Log Stream ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteLogStream(...args) { + return this.logStreams.delete(...args); + } -/** - * Get users for a given email address - * - * @method getUsersByEmail - * @memberOf module:management.ManagementClient.prototype - * - * @example - * This method takes an email address as the first argument, - * and returns all users with that email address - * - * - * auth0.getUsersByEmail(email, function (err, users) { - * console.log(users); - * }); - * - * @param {String} [email] Email Address of users to locate - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getUsersByEmail', 'users.getByEmail'); + /** + * Update an existing Log Stream. + * + * @example + * var params = { id: LOG_STREAM_ID }; + * var data = { name: 'my-log-stream'}; + * management.updateLogStream(params, data, function (err, logStream) { + * if (err) { + * // Handle error. + * } + * + * console.log(logStream.name); // 'my-log-stream'. + * }); + * @param {object} params Rule parameters. + * @param {string} params.id Rule ID. + * @param {object} data Updated rule data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateLogStream(...args) { + return this.logStreams.update(...args); + } -/** - * Get a user by its id. - * - * @method getUser - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getUser({ id: USER_ID }, function (err, user) { - * console.log(user); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getUser', 'users.get'); + /** + * Create a new resource server. + * + * @example + * management.createResourceServer(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Resource Server created. + * }); + * @param {object} data Resource Server data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createResourceServer(...args) { + return this.resourceServers.create(...args); + } -/** - * Delete all users. - * - * @method deleteAllUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteAllUsers(function (err) { - * if (err) { - * // Handle error. - * } - * - * // Users deleted - * }); - * - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - * - * @deprecated This method will be removed in the next major release. - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteAllUsers', 'users.deleteAll'); + /** + * Get all resource servers. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getResourceServers(params, function (err, resourceServers) { + * console.log(resourceServers.length); + * }); + * @param {object} [params] Resource Servers parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getResourceServers(...args) { + return this.resourceServers.getAll(...args); + } -/** - * Delete a user by its id. - * - * @method deleteUser - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteUser({ id: USER_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // User deleted. - * }); - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteUser', 'users.delete'); + /** + * Get a Resource Server. + * + * @example + * management.getResourceServer({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) { + * if (err) { + * // Handle error. + * } + * + * console.log(resourceServer); + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getResourceServer(...args) { + return this.resourceServers.get(...args); + } -/** - * Create a new user. - * - * @method createUser - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createUser(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // User created. - * }); - * - * @param {Object} data User data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createUser', 'users.create'); + /** + * Delete an existing resource server. + * + * @example + * management.deleteResourceServer({ id: RESOURCE_SERVER_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Resource Server deleted. + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteResourceServer(...args) { + return this.resourceServers.delete(...args); + } -/** - * Update a user by its id. - * - * @method updateUser - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID }; - * - * management.updateUser(params, data, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user parameters. - * @param {String} params.id The user id. - * @param {Object} data New user data. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateUser', 'users.update'); + /** + * Update an existing resource server. + * + * @example + * var data = { name: 'newResourceServerName' }; + * var params = { id: RESOURCE_SERVER_ID }; + * + * management.updateResourceServer(params, data, function (err, resourceServer) { + * if (err) { + * // Handle error. + * } + * + * console.log(resourceServer.name); // 'newResourceServerName' + * }); + * @param {object} params Resource Server parameters. + * @param {string} params.id Resource Server ID. + * @param {object} data Updated Resource Server data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateResourceServer(...args) { + return this.resourceServers.update(...args); + } -/** - * Update the user metadata for a user. - * - * @method updateUserMetadata - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID }; - * var metadata = { - * address: '123th Node.js Street' - * }; - * - * management.updateUserMetadata(params, metadata, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Object} metadata New user metadata. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateUserMetadata', 'users.updateUserMetadata'); + /** + * Set a new rules config. + * + * @example + * var params = { key: RULE_CONFIG_KEY }; + * var data = { value: RULES_CONFIG_VALUE }; + * + * management.setRulesConfig(params, data, function (err, rulesConfig) { + * if (err) { + * // Handle error. + * } + * + * // Rules Config set. + * }); + * @param {object} params Rule Config parameters. + * @param {string} params.key Rule Config key. + * @param {object} data Rule Config Data parameters. + * @param {string} data.value Rule Config Data value. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + setRulesConfig(...args) { + return this.rulesConfigs.set(...args); + } -/** - * Update the app metadata for a user. - * - * @method updateAppMetadata - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID }; - * var metadata = { - * foo: 'bar' - * }; - * - * management.updateAppMetadata(params, metadata, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Updated user. - * console.log(user); - * }); - * - * @param {Object} params The user data object.. - * @param {String} params.id The user id. - * @param {Object} metadata New app metadata. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateAppMetadata', 'users.updateAppMetadata'); + /** + * Get rules config. + * + * @param {Function} [cb] Callback function. + * @example + * + * management.getRulesConfigs(function (err, rulesConfigs) { + * if (err) { + * // Handle error. + * } + * + * // Get Rules Configs. + * }); + * @returns {Promise|undefined} + */ + getRulesConfigs(...args) { + return this.rulesConfigs.getAll(...args); + } -/** - * Delete a multifactor provider for a user. - * - * @method deleteUserMultifactor - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; - * - * management.deleteUserMultifactor(params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users accounts unlinked. - * }); - * - * @param {Object} params Data object. - * @param {String} params.id The user id. - * @param {String} params.provider Multifactor provider. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'deleteUserMultifactor', - 'users.deleteMultifactorProvider' -); + /** + * Delete rules config. + * + * @example + * + * management.deleteRulesConfig({ key: RULE_CONFIG_KEY }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Rules Config deleted. + * }); + * @param {object} params Rule Configs parameters. + * @param {string} params.key Rule Configs key. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteRulesConfig(...args) { + return this.rulesConfigs.delete(...args); + } -/** - * Delete a multifactor provider for a user. - * - * @method deleteUserMultifcator - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER }; - * - * management.deleteUserMultifcator(params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users accounts unlinked. - * }); - * - * @param {Object} params Data object. - * @param {String} params.id The user id. - * @param {String} params.provider Multifactor provider. - * @param {Function} [cb] Callback function - * - * @return {Promise|undefined} - * - * @deprecated The function name has a typo. - * We're shipping this so it doesn't break compatibility. - * Use {@link deleteUserMultifactor} instead. - */ -utils.wrapPropertyMethod( - ManagementClient, - 'deleteUserMultifcator', - 'users.deleteMultifactorProvider' -); + /** + * Create an Auth0 Custom Domain. + * + * @example + * management.createCustomDomain(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // CustomDomain created. + * }); + * @param {object} data The custom domain data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createCustomDomain(...args) { + return this.customDomains.create(...args); + } -/** - * Unlink the given accounts. - * - * @method unlinkUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID }; - * - * management.unlinkUsers(params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users accounts unlinked. - * }); - * - * @param {Object} params Linked users data. - * @param {String} params.id Primary user ID. - * @param {String} params.provider Identity provider in use. - * @param {String} params.user_id Secondary user ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'unlinkUsers', 'users.unlink'); + /** + * Get all Auth0 CustomDomains. + * + * @example + * management.getCustomDomains(function (err, customDomains) { + * console.log(customDomains.length); + * }); + * @returns {Promise|undefined} + */ + getCustomDomains(...args) { + return this.customDomains.getAll(...args); + } -/** - * Link the user with another account. - * - * @method linkUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var userId = 'USER_ID'; - * var params = { - * user_id: 'OTHER_USER_ID', - * connection_id: 'CONNECTION_ID' - * }; - * - * management.linkUsers(userId, params, function (err, user) { - * if (err) { - * // Handle error. - * } - * - * // Users linked. - * }); - * - * @param {String} userId ID of the primary user. - * @param {Object} params Secondary user data. - * @param {String} params.user_id ID of the user to be linked. - * @param {String} params.connection_id ID of the connection to be used. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'linkUsers', 'users.link'); + /** + * Get a Custom Domain. + * + * @example + * management.getCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { + * if (err) { + * // Handle error. + * } + * + * console.log(customDomain); + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getCustomDomain(...args) { + return this.customDomains.get(...args); + } -/** - * Get user's log events. - * - * @method getUserLogs - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true }; - * - * management.getUserLogs(params, function (err, logs) { - * if (err) { - * // Handle error. - * } - * - * console.log(logs); - * }); - * - * @param {Object} params Get logs data. - * @param {String} params.id User id. - * @param {Number} params.per_page Number of results per page. - * @param {Number} params.page Page number, zero indexed. - * @param {String} params.sort The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1. - * @param {Boolean} params.include_totals true if a query summary must be included in the result, false otherwise. Default false; - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getUserLogs', 'users.logs'); + /** + * Verify a Custom Domain. + * + * @example + * management.verifyCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { + * if (err) { + * // Handle error. + * } + * + * console.log(customDomain); + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + verifyCustomDomain(...args) { + return this.customDomains.verify(...args); + } -/** - * Get a list of a user's Guardian enrollments. - * - * @method getGuardianEnrollments - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) { - * console.log(enrollments); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'getGuardianEnrollments', - 'users.getGuardianEnrollments' -); + /** + * Delete a Custom Domain. + * + * @example + * management.deleteCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // CustomDomain deleted. + * }); + * @param {object} params Custom Domain parameters. + * @param {string} params.id Custom Domain ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteCustomDomain(...args) { + return this.customDomains.delete(...args); + } -/** - * Generate new Guardian recovery code. - * - * @method regenerateRecoveryCode - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.regenerateRecoveryCode({ id: USER_ID }, function (err, newRecoveryCode) { - * console.log(newRecoveryCode); - * }); - * - * @param {Object} data The user data object. - * @param {String} data.id The user id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'regenerateRecoveryCode', - 'users.regenerateRecoveryCode' -); + /** + * Create a Guardian enrollment ticket. + * + * @example + * management.createGuardianEnrollmentTicket(function (err, ticket) { + * console.log(ticket); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createGuardianEnrollmentTicket(...args) { + return this.guardian.createEnrollmentTicket(...args); + } + + /** + * Get a list of Guardian factors and statuses. + * + * @example + * management.getGuardianFactors(function (err, factors) { + * console.log(factors.length); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianFactors(...args) { + return this.guardian.getFactors(...args); + } -/** - * Get a single Guardian enrollment. - * - * @method getGuardianEnrollment - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getGuardianEnrollment({ id: ENROLLMENT_ID }, function (err, enrollment) { - * console.log(enrollment); - * }); - * - * @param {Object} data The Guardian enrollment data object. - * @param {String} data.id The Guardian enrollment id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'getGuardianEnrollment', - 'guardian.getGuardianEnrollment' -); + /** + * Get the settings of a Guardian factor. + * + * @example + * management.getGuardianFactorSettings({ name: 'duo' }, function (err, settings) { + * console.log(settings); + * }); + * @param {object} params Factor parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianFactorSettings(...args) { + return this.guardian.getFactorSettings(...args); + } -/** - * Delete a user's Guardian enrollment. - * - * @method deleteGuardianEnrollment - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteGuardianEnrollment({ id: ENROLLMENT_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email provider deleted. - * }); - * - * @param {Object} data The Guardian enrollment data object. - * @param {String} data.id The Guardian enrollment id. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'deleteGuardianEnrollment', - 'guardian.deleteGuardianEnrollment' -); + /** + * Get Guardian factor provider configuration + * + * @example + * management.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) { + * console.log(provider); + * }); + * @param {object} params Factor provider parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianFactorProvider(...args) { + return this.guardian.getFactorProvider(...args); + } -/** - * Get all blacklisted tokens. - * - * @method getBlacklistedTokens - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getBlacklistedTokens(function (err, tokens) { - * console.log(tokens.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getBlacklistedTokens', 'blacklistedTokens.getAll'); + /** + * Update Guardian's factor provider + * + * @example + * management.updateGuardianFactorProvider({ name: 'sms', provider: 'twilio' }, { + * messaging_service_sid: 'XXXXXXXXXXXXXX', + * auth_token: 'XXXXXXXXXXXXXX', + * sid: 'XXXXXXXXXXXXXX' + * }, function (err, provider) { + * console.log(provider); + * }); + * @param {object} params Factor provider parameters. + * @param {object} data Updated Factor provider data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianFactorProvider(...args) { + return this.guardian.updateFactorProvider(...args); + } -/** - * Blacklist a new token. - * - * @method blacklistToken - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var token = { - * aud: 'aud', - * jti: 'jti' - * }; - * - * management.blacklistToken(token, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Token blacklisted. - * }); - * - * @param {Object} token Token data. - * @param {String} token.aud Audience (your app client ID). - * @param {String} token.jti The JWT ID claim. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'blacklistToken', 'blacklistedTokens.add'); + /** + * Update a Guardian's factor settings + * + * @example + * management.updateGuardianFactorSettings( + * { name: 'webauthn-roaming' }, + * { userVerification: 'discouraged', overrideRelyingParty: false }, + * function (err, settings) { + * console.log(settings); + * }) + * @param {object} params Factor parameters. + * @param {object} data Updated Factor settings data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianFactorSettings(...args) { + return this.guardian.updateFactorSettings(...args); + } -/** - * Get the email provider. - * - * @method getEmailProvider - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getEmailProvider(function (err, provider) { - * console.log(provider.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getEmailProvider', 'emailProvider.get'); + /** + * Get Guardian enrollment and verification factor templates + * + * @example + * management.getGuardianFactorTemplates({ name: 'sms' }, function (err, templates) { + * console.log(templates); + * }); + * @param {object} params Factor parameters. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianFactorTemplates(...args) { + return this.guardian.getFactorTemplates(...args); + } -/** - * Configure the email provider. - * - * @method configureEmailProvider - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.configureEmailProvider(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email provider configured. - * }); - * - * @param {Object} data The email provider data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'configureEmailProvider', 'emailProvider.configure'); + /** + * Update Guardian enrollment and verification factor templates + * + * @example + * management.updateGuardianFactorTemplates({ name: 'sms' }, { + * enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.", + * verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}" + * }, function (err, templates) { + * console.log(templates); + * }); + * @param {object} params Factor parameters. + * @param {object} data Updated factor templates data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianFactorTemplates(...args) { + return this.guardian.updateFactorTemplates(...args); + } -/** - * Delete email provider. - * - * @method deleteEmailProvider - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteEmailProvider(function (err) { - * if (err) { - * // Handle error. - * } - * - * // Email provider deleted. - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteEmailProvider', 'emailProvider.delete'); + /** + * Update Guardian Factor + * + * @example + * management.updateGuardianFactor({ name: 'sms' }, { + * enabled: true + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Factor parameters. + * @param {object} data Updated factor data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianFactor(...args) { + return this.guardian.updateFactor(...args); + } -/** - * Update the email provider. - * - * @method updateEmailProvider - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.updateEmailProvider(params, data, function (err, provider) { - * if (err) { - * // Handle error. - * } - * - * // Updated email provider. - * console.log(provider); - * }); - * - * @param {Object} params Email provider parameters. - * @param {Object} data Updated email provider data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateEmailProvider', 'emailProvider.update'); + /** + * Get enabled Guardian policies + * + * @example + * management.getGuardianPolicies(function (err, policies) { + * console.log(policies); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianPolicies(...args) { + return this.guardian.getPolicies(...args); + } -/** - * Get a the active users count. - * - * @method getActiveUsersCount - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getActiveUsersCount(function (err, usersCount) { - * if (err) { - * // Handle error. - * } - * - * console.log(usersCount); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getActiveUsersCount', 'stats.getActiveUsersCount'); + /** + * Update enabled Guardian policies + * + * @example + * management.updateGuardianPolicies({}, [ + * 'all-applications' + * ], function (err, policies) { + * console.log(policies); + * }); + * @param {object} params Parameters. + * @param {string[]} data Policies to enable. Empty array disables all policies. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianPolicies(...args) { + return this.guardian.updatePolicies(...args); + } -/** - * Get the daily stats. - * - * @method getDailyStats - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * from: '{YYYYMMDD}', // First day included in the stats. - * to: '{YYYYMMDD}' // Last day included in the stats. - * }; - * - * management.getDaily(params, function (err, stats) { - * if (err) { - * // Handle error. - * } - * - * console.log(stats); - * }); - * - * @param {Object} params Stats parameters. - * @param {String} params.from The first day in YYYYMMDD format. - * @param {String} params.to The last day in YYYYMMDD format. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getDailyStats', 'stats.getDaily'); + /** + * Get the Guardian phone factor's selected provider + * + * @example + * management.getGuardianPhoneFactorSelectedProvider(function (err, selectedProvider) { + * console.log(selectedProvider); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianPhoneFactorSelectedProvider(...args) { + return this.guardian.getPhoneFactorSelectedProvider(...args); + } -/** - * Get the tenant settings.. - * - * @method getTenantSettings - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getSettings(function (err, settings) { - * if (err) { - * // Handle error. - * } - * - * console.log(settings); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getTenantSettings', 'tenant.getSettings'); + /** + * Update the Guardian phone factor's selected provider + * + * @example + * management.updateGuardianPhoneFactorSelectedProvider({}, { + * provider: 'twilio' + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Parameters. + * @param {object} data Updated selected provider data. + * @param {string} data.provider Name of the selected provider + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianPhoneFactorSelectedProvider(...args) { + return this.guardian.updatePhoneFactorSelectedProvider(...args); + } -/** - * Update the tenant settings. - * - * @method updateTenantSettings - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.updateTenantSettings(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data The new tenant settings. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateTenantSettings', 'tenant.updateSettings'); + /** + * Get the Guardian phone factor's message types + * + * @example + * management.getGuardianPhoneFactorMessageTypes(function (err, messageTypes) { + * console.log(messageTypes); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getGuardianPhoneFactorMessageTypes(...args) { + return this.guardian.getPhoneFactorMessageTypes(...args); + } -/** - * Get a job by its ID. - * - * @method getJob - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * id: '{JOB_ID}' - * }; - * - * management.getJob(params, function (err, job) { - * if (err) { - * // Handle error. - * } - * - * // Retrieved job. - * console.log(job); - * }); - * - * @param {Object} params Job parameters. - * @param {String} params.id Job ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getJob', 'jobs.get'); + /** + * Update the Guardian phone factor's message types + * + * @example + * management.updateGuardianPhoneFactorMessageTypes({}, { + * message_types: ['sms', 'voice'] + * }, function (err, factor) { + * console.log(factor); + * }); + * @param {object} params Parameters. + * @param {object} data Updated selected provider data. + * @param {string[]} data.message_types Message types (only `"sms"` and `"voice"` are supported). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateGuardianPhoneFactorMessageTypes(...args) { + return this.guardian.updatePhoneFactorMessageTypes(...args); + } -/** - * Given a path to a file and a connection id, create a new job that imports the - * users contained in the file and associate them with the given connection. - * - * @method importUsers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * connection_id: '{CONNECTION_ID}', - * users: '{PATH_TO_USERS_FILE}' - * }; - * - * management.get(params, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data Users import data. - * @param {String} data.connectionId Connection for the users insertion. - * @param {String} data.users Path to the users data file. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'importUsers', 'jobs.importUsers'); + /** + * Get all roles. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getRoles(params, function (err, roles) { + * console.log(roles.length); + * }); + * @param {object} [params] Roles parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRoles(...args) { + return this.roles.getAll(...args); + } -/** - * Send a verification email to a user. - * - * @method sendEmailVerification - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * user_id: '{USER_ID}' - * }; - * - * management.sendEmailVerification(function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Object} data User data object. - * @param {String} data.user_id ID of the user to be verified. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'sendEmailVerification', 'jobs.verifyEmail'); + /** + * Create a new role. + * + * @example + * data = {"name": "test1","description": "123"} + * management.createRole(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Role created. + * }); + * @param {object} data Role data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createRole(...args) { + return this.roles.create(...args); + } -/** - * Create a new password change ticket. - * - * @method createPasswordChangeTicket - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { - * result_url: '{REDIRECT_URL}', // Redirect after using the ticket. - * user_id: '{USER_ID}', // Optional. - * email: '{USER_EMAIL}', // Optional. - * new_password: '{PASSWORD}' - * }; - * - * auth0.createPasswordChangeTicket(params, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Function} [cb] Callback function. - * @return {Promise} - */ -utils.wrapPropertyMethod(ManagementClient, 'createPasswordChangeTicket', 'tickets.changePassword'); + /** + * Get an Auth0 role. + * + * @example + * management.getRole({ id: ROLE_ID }, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(role); + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getRole(...args) { + return this.roles.get(...args); + } -/** - * Create an email verification ticket. - * - * @method createEmailVerificationTicket - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var data = { - * user_id: '{USER_ID}', - * result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used. - * }; - * - * auth0.createEmailVerificationTicket(data, function (err) { - * if (err) { - * // Handle error. - * } - * }); - * - * @param {Function} [cb] Callback function. - * @return {Promise} - */ -utils.wrapPropertyMethod(ManagementClient, 'createEmailVerificationTicket', 'tickets.verifyEmail'); + /** + * Delete an existing role. + * + * @example + * management.deleteRole({ id: ROLE_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Role deleted. + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteRole(...args) { + return this.roles.delete(...args); + } -/** - * Get an Auth0 log. - * - * @method getLog - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getLog({ id: EVENT_ID }, function (err, log) { - * if (err) { - * // Handle error. - * } - * - * console.log(log); - * }); - * - * @param {Object} params Log parameters. - * @param {String} params.id Event ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getLog', 'logs.get'); + /** + * Update an existing role. + * + * @example + * var params = { id: ROLE_ID }; + * var data = { name: 'my-role'}; + * management.updateRole(params, data, function (err, role) { + * if (err) { + * // Handle error. + * } + * + * console.log(role.name); // 'my-role'. + * }); + * @param {object} params Role parameters. + * @param {string} params.id Role ID. + * @param {object} data Updated role data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateRole(...args) { + return this.roles.update(...args); + } -/** - * Get all logs. - * - * @method getLogs - * @memberOf module:management.ManagementClient.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings and the search query. If pagination options are - * not present, the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 2 - * }; - * - * management.getLogs(params, function (err, logs) { - * console.log(logs.length); - * }); - * - * @param {Object} [params] Logs params. - * @param {String} [params.q] Search Criteria using Query String Syntax - * @param {Number} [params.page] Page number. Zero based - * @param {Number} [params.per_page] The amount of entries per page - * @param {String} [params.sort] The field to use for sorting. - * @param {String} [params.fields] A comma separated list of fields to include or exclude - * @param {Boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise. - * @param {Boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getLogs', 'logs.getAll'); + /** + * Get permissions for a given role + * + * @example + * var params = { id :'ROLE_ID'}; + * @example + * This method takes a roleId and + * returns all permissions within that role + * + * + * + * management.getPermissionsInRole(params, function (err, permissions) { + * console.log(permissions); + * }); + * @param {string} [roleId] Id of the role + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPermissionsInRole(...args) { + return this.roles.getPermissions(...args); + } -/** - * Create a new resource server. - * - * @method createResourceServer - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.createResourceServer(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Resource Server created. - * }); - * - * @param {Object} data Resource Server data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createResourceServer', 'resourceServers.create'); + /** + * Add permissions in a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.addPermissionsInRole(params, data, function (err, permissions) { + * console.log(permissions); + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + addPermissionsInRole(...args) { + return this.roles.addPermissions(...args); + } + + /** + * Remove permissions from a role + * + * @example + * var params = { id :'ROLE_ID'}; + * var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]}; + * + * management.removePermissionsFromRole(params, data, function (err, permissions) { + * console.log(permissions); + * }); + * @param {string} params.id ID of the Role. + * @param {object} data permissions data + * @param {string} data.permissions Array of permissions + * @param {string} data.permissions.permission_name Name of a permission + * @param {string} data.permissions.resource_server_identifier Identifier for a resource + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removePermissionsFromRole(...args) { + return this.roles.removePermissions(...args); + } + + /** + * Get users in a given role + * + * @example + * var params = { + * id: 'ROLE_ID', + * per_page: 50, + * page: 0 + * }; + * @example + * This method takes a roleId and returns all users within that role. Supports offset (page, per_page) and checkpoint pagination (from, take). You must use checkpoint pagination to retrieve beyond the first 1000 records. + * + * + * management.getUsersInRole(params, function (err, users) { + * console.log(users); + * }); + * @param {string} [id] Id of the role + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {string} [params.from] Optional id from which to start selection. + * @param {number} [params.take] The total amount of entries to retrieve when using the from parameter. Defaults to 50. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getUsersInRole(...args) { + return this.roles.getUsers(...args); + } -/** - * Get all resource servers. - * - * @method getResourceServers - * @memberOf module:management.ManagementClient.prototype - * - * @example - * This method takes an optional object as first argument that may be used to - * specify pagination settings. If pagination options are not present, - * the first page of a limited number of results will be returned. - * - * - * // Pagination settings. - * var params = { - * per_page: 10, - * page: 0 - * }; - * - * management.getResourceServers(params, function (err, resourceServers) { - * console.log(resourceServers.length); - * }); - * - * @param {Object} [params] Resource Servers parameters. - * @param {Number} [params.per_page] Number of results per page. - * @param {Number} [params.page] Page number, zero indexed. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getResourceServers', 'resourceServers.getAll'); + /** + * Get all hooks. + * + * @example + * This method takes an optional object as first argument that may be used to + * specify pagination settings. If pagination options are not present, + * the first page of a limited number of results will be returned. + * + * + * // Pagination settings. + * var params = { + * per_page: 10, + * page: 0 + * }; + * + * management.getHooks(params, function (err, hooks) { + * console.log(hooks.length); + * }); + * @param {object} [params] Hooks parameters. + * @param {number} [params.per_page] Number of results per page. + * @param {number} [params.page] Page number, zero indexed. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getHooks(...args) { + return this.hooks.getAll(...args); + } -/** - * Get a Resource Server. - * - * @method getResourceServer - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.getResourceServer({ id: RESOURCE_SERVER_ID }, function (err, resourceServer) { - * if (err) { - * // Handle error. - * } - * - * console.log(resourceServer); - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getResourceServer', 'resourceServers.get'); + /** + * Get an Auth0 hook. + * + * @example + * management.getHook({ id: HOOK_ID }, function (err, hook) { + * if (err) { + * // Handle error. + * } + * + * console.log(hook); + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getHook(...args) { + return this.hooks.get(...args); + } -/** - * Delete an existing resource server. - * - * @method deleteResourceServer - * @memberOf module:management.ManagementClient.prototype - * - * @example - * management.deleteResourceServer({ id: RESOURCE_SERVER_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Resource Server deleted. - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteResourceServer', 'resourceServers.delete'); + /** + * Create a new hook. + * + * @example + * management.createHook(data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Hook created. + * }); + * @param {object} data Hook data object. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + createHook(...args) { + return this.hooks.create(...args); + } -/** - * Update an existing resource server. - * - * @method updateResourceServer - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var data = { name: 'newResourceServerName' }; - * var params = { id: RESOURCE_SERVER_ID }; - * - * management.updateResourceServer(params, data, function (err, resourceServer) { - * if (err) { - * // Handle error. - * } - * - * console.log(resourceServer.name); // 'newResourceServerName' - * }); - * - * @param {Object} params Resource Server parameters. - * @param {String} params.id Resource Server ID. - * @param {Object} data Updated Resource Server data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateResourceServer', 'resourceServers.update'); + /** + * Update an existing hook. + * + * @example + * var params = { id: HOOK_ID }; + * var data = { name: 'my-hook'}; + * management.updateHook(params, data, function (err, hook) { + * if (err) { + * // Handle error. + * } + * + * console.log(hook.name); // 'my-hook'. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Updated hook data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateHook(...args) { + return this.hooks.update(...args); + } -/** - * Set a new rules config. - * - * @method setRulesConfig - * @memberOf module:management.ManagementClient.prototype - * - * @example - * var params = { key: RULE_CONFIG_KEY }; - * var data = { value: RULES_CONFIG_VALUE }; - * - * management.setRulesConfig(params, data, function (err, rulesConfig) { - * if (err) { - * // Handle error. - * } - * - * // Rules Config set. - * }); - * - * @param {Object} params Rule Config parameters. - * @param {String} params.key Rule Config key. - * @param {Object} data Rule Config Data parameters. - * @param {String} data.value Rule Config Data value. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'setRulesConfig', 'rulesConfigs.set'); + /** + * Delete an existing hook. + * + * @example + * auth0.deleteHook({ id: HOOK_ID }, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Hook deleted. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteHook(...args) { + return this.hooks.delete(...args); + } -/** - * Get rules config. - * - * @method getRulesConfigs - * @memberOf module:management.ManagementClient.prototype - * - * @example - * - * management.getRulesConfigs(function (err, rulesConfigs) { - * if (err) { - * // Handle error. - * } - * - * // Get Rules Configs. - * }); - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getRulesConfigs', 'rulesConfigs.getAll'); + /** + * Get an Auth0 hook's secrets. + * + * @example + * var params = { id: HOOK_ID } + * management.getHookSecrets(params, function (err, secrets) { + * if (err) { + * // Handle error. + * } + * + * console.log(secrets); + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getHookSecrets(...args) { + return this.hooks.getSecrets(...args); + } -/** - * Delete rules config. - * - * @method deleteRulesConfig - * @memberOf module:management.ManagementClient.prototype - * - * @example - * - * management.deleteRulesConfig({ key: RULE_CONFIG_KEY }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // Rules Config deleted. - * }); - * - * @param {Object} params Rule Configs parameters. - * @param {String} params.key Rule Configs key. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteRulesConfig', 'rulesConfigs.delete'); + /** + * Add hook screts. + * + * @example + * var params = { id: 'HOOK_ID' } + * var data = { DB_PASSWORD: 'password1', API_TOKEN: 'secret' } + * management.addHookScrets(params, data, function (err, secrets) { + * if (err) { + * // Handle error. + * } + * + * // Hook secrets created. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Secrets key/value pairs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + addHookSecrets(...args) { + return this.hooks.addSecrets(...args); + } -/** - * Create an Auth0 Custom Domain. - * - * @method create - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.createCustomDomain(data, function (err) { - * if (err) { - * // Handle error. - * } - * - * // CustomDomain created. - * }); - * - * @param {Object} data The custom domain data object. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'createCustomDomain', 'customDomains.create'); + /** + * Update an existing hook. + * + * @example + * var params = { id: HOOK_ID }; + * var data = { API_TOKEN: 'updated-secret'}; + * management.updateHookSecrets(params, data, function (err, secrets) { + * if (err) { + * // Handle error. + * } + * + * console.log(secrets) + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Secrets key/value pairs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateHookSecrets(...args) { + return this.hooks.updateSecrets(...args); + } -/** - * Get all Auth0 CustomDomains. - * - * @method getAll - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.getCustomDomains(function (err, customDomains) { - * console.log(customDomains.length); - * }); - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getCustomDomains', 'customDomains.getAll'); + /** + * Delete an existing hook. + * + * @example + * var params = { id: HOOK_ID } + * var data = ['API_TOKEN', 'DB_PASSWORD'] + * auth0.removeHookSecrets(params, data, function (err) { + * if (err) { + * // Handle error. + * } + * + * // Hook deleted. + * }); + * @param {object} params Hook parameters. + * @param {string} params.id Hook ID. + * @param {object} data Secrets key/value pairs + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + removeHookSecrets(...args) { + return this.hooks.removeSecrets(...args); + } -/** - * Get a Custom Domain. - * - * @method get - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.getCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { - * if (err) { - * // Handle error. - * } - * - * console.log(customDomain); - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getCustomDomain', 'customDomains.get'); + /** + * Returns the access_token. + * + * @returns {Promise} Promise returning an access_token. + */ + getAccessToken(...args) { + return this.tokenProvider.getAccessToken(...args); + } -/** - * Verify a Custom Domain. - * - * @method verify - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.verifyCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err, customDomain) { - * if (err) { - * // Handle error. - * } - * - * console.log(customDomain); - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'verifyCustomDomain', 'customDomains.verify'); + /** + * Update the branding settings. + * + * @example + * management.updateBrandingSettings(data, function (err, branding) { + * if (err) { + * // Handle error. + * } + * + * // Updated branding + * console.log(branding); + * }); + * @param {object} params Branding parameters. + * @param {object} data Updated branding data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateBrandingSettings(...args) { + return this.branding.updateSettings(...args); + } -/** - * Delete a Custom Domain. - * - * @method delete - * @memberOf module:management.CustomDomainsManager.prototype - * - * @example - * management.deleteCustomDomain({ id: CUSTOM_DOMAIN_ID }, function (err) { - * if (err) { - * // Handle error. - * } - * - * // CustomDomain deleted. - * }); - * - * @param {Object} params Custom Domain parameters. - * @param {String} params.id Custom Domain ID. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'deleteCustomDomain', 'customDomains.delete'); + /** + * Get the branding settings.. + * + * @example + * management.getBrandingSettings(data, function (err, branding) { + * if (err) { + * // Handle error. + * } + * + * // Branding + * console.log(branding); + * }); + * @param {object} params Branding parameters. + * @param {object} data Branding data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getBrandingSettings(...args) { + return this.branding.getSettings(...args); + } -/** - * Create a Guardian enrollment ticket. - * - * @method createGuardianEnrollmentTicket - * @memberOf module:management.GuardianManager.prototype - * - * @example - * management.createGuardianEnrollmentTicket(function (err, ticket) { - * console.log(ticket); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'createGuardianEnrollmentTicket', - 'guardian.tickets.create' -); + /** + * Get the new universal login template. + * + * @example + * management.getBrandingUniversalLoginTemplate(data, function (err, template) { + * if (err) { + * // Handle error. + * } + * + * // Branding + * console.log(template); + * }); + * @param {object} params Branding parameters (leave empty). + * @param {object} data Branding data (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getBrandingUniversalLoginTemplate(...args) { + return this.branding.getUniversalLoginTemplate(...args); + } -/** - * Get a list of Guardian factors and statuses. - * - * @method getGuardianFactors - * @memberOf module:management.GuardianManager.prototype - * - * management.getGuardianFactors(function (err, factors) { - * console.log(factors.length); - * }); - * - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'getGuardianFactors', 'guardian.factors.getAll'); + /** + * Set the new universal login template. + * + * @example + * management.setBrandingUniversalLoginTemplate({}, { template: "a template" }, function (err, template) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Branding parameters (leave empty). + * @param {object} template Branding data (object with template field). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + setBrandingUniversalLoginTemplate(...args) { + return this.branding.setUniversalLoginTemplate(...args); + } -/** - * Get Guardian factor provider configuration - * - * @method getGuardianFactorProvider - * @memberOf module:management.GuardianManager.prototype - * - * management.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) { - * console.log(provider); - * }); - * - * @param {Object} params Factor provider parameters. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'getGuardianFactorProvider', - 'guardian.factorsProviders.get' -); + /** + * Delete the new universal login template. + * + * @example + * management.deleteBrandingUniversalLoginTemplate(template, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} params Branding parameters (leave empty). + * @param {object} data Branding data (leave empty). + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + deleteBrandingUniversalLoginTemplate(...args) { + return this.branding.deleteUniversalLoginTemplate(...args); + } -/** - * Update Guardian's factor provider - * - * @method updateFactorProvider - * @memberOf module:management.GuardianManager.prototype - * - * management.updateGuardianFactorProvider({ name: 'sms', provider: 'twilio' }, { - * messaging_service_sid: 'XXXXXXXXXXXXXX', - * auth_token: 'XXXXXXXXXXXXXX', - * sid: 'XXXXXXXXXXXXXX' - * }, function(err, provider) { - * console.log(provider); - * }); - * - * @param {Object} params Factor provider parameters. - * @param {Object} data Updated Factor provider data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'updateGuardianFactorProvider', - 'guardian.factorsProviders.update' -); + /** + * Update the tenant migrations. + * + * @example + * data = { flags: { migration: true } }; + * management.updateMigrations(data, function (err, migrations) { + * if (err) { + * // Handle error. + * } + * + * // Updated migrations flags + * console.log(migrations.flags); + * }); + * @param {object} data Updated migrations data. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updateMigrations(...args) { + return this.migrations.updateMigrations(...args); + } -/** - * Get Guardian enrollment and verification factor templates - * - * @method getGuardianFactorTemplates - * @memberOf module:management.GuardianManager.prototype - * - * management.getGuardianFactorTemplates({ name: 'sms' }, function (err, templates) { - * console.log(templates); - * }); - * - * @param {Object} params Factor parameters. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'getGuardianFactorTemplates', - 'guardian.factorsTemplates.get' -); + /** + * Get migrations flags + * + * @example + * management.getMigrations(function (err, migrations) { + * if (err) { + * // Handle error. + * } + * + * // Migration flags + * console.log(migrations.flags); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getMigrations(...args) { + return this.migrations.getMigrations(...args); + } -/** - * Update Guardian enrollment and verification factor templates - * - * @method updateGuardianFactorTemplates - * @memberOf module:management.GuardianManager.prototype - * - * management.updateGuardianFactorTemplates({ name: 'sms' }, { - * enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.", - * verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}" - * }, function(err, templates) { - * console.log(templates); - * }); - * - * @param {Object} params Factor parameters. - * @param {Object} data Updated factor templates data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod( - ManagementClient, - 'updateGuardianFactorTemplates', - 'guardian.factorsTemplates.update' -); + /** + * Get prompts settings.. + * + * @example + * management.getPromptsSettings(function (err, settings) { + * console.log(settings); + * }); + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + getPromptsSettings(...args) { + return this.prompts.getSettings(...args); + } -/** - * Update Guardian Factor - * - * @method updateGuardianFactor - * @memberOf module.GuardianManager.prototype - * - * management.updateGuardianFactor({ name: 'sms' }, { - * enabled: true - * }, function(err, factor) { - * console.log(factor); - * }); - * - * @param {Object} params Factor parameters. - * @param {Object} data Updated factor data. - * @param {Function} [cb] Callback function. - * - * @return {Promise|undefined} - */ -utils.wrapPropertyMethod(ManagementClient, 'updateGuardianFactor', 'guardian.factors.update'); + /** + * Update prompts settings. + * + * @example + * management.updatePromptsSettings(data, function (err) { + * if (err) { + * // Handle error. + * } + * }); + * @param {object} data The new prompts settings. + * @param {Function} [cb] Callback function. + * @returns {Promise|undefined} + */ + updatePromptsSettings(...args) { + return this.prompts.updateSettings(...args); + } + /** + * Retrieve custom text for a specific prompt and language. + * + * @example + * var params = { prompt: PROMPT_NAME, language: LANGUAGE }; + * + * management.prompts.getCustomTextByLanguage(params, function (err, customText) { + * console.log('CustomText', customText); + * }); + * @param {object} params Data object. + * @param {string} params.prompt Name of the prompt. + * @param {string} params.language Language to retrieve. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + getCustomTextByLanguage(...args) { + return this.prompts.getCustomTextByLanguage(...args); + } + + /** + * Set custom text for a specific prompt. + * + * @example + * var params = { prompt: PROMPT_NAME, language: LANGUAGE, body: BODY_OBJECT }; + * + * management.prompts.updateCustomTextByLanguage(params, function (err, customText) { + * console.log('CustomText', customText); + * }); + * @param {object} params Data object. + * @param {string} params.prompt Name of the prompt. + * @param {string} params.language Language to retrieve. + * @param {object} params.body An object containing custom dictionaries for a group of screens. + * @param {Function} [cb] Callback function + * @returns {Promise|undefined} + */ + updateCustomTextByLanguage(...args) { + return this.prompts.updateCustomTextByLanguage(...args); + } +} module.exports = ManagementClient; diff --git a/src/utils.js b/src/utils.js index 8ba259f61..e553250ee 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,73 +1,60 @@ -var Promise = require('bluebird'); -var request = require('request'); - -/** - * @module utils - */ -var utils = (module.exports = {}); +const pkg = require('../package.json'); /** * Given a JSON string, convert it to its base64 representation. * - * @method jsonToBase64 - * @memberOf module:utils + * @param {object} json Json data + * @returns {string} */ -utils.jsonToBase64 = function(json) { - var bytes = new Buffer(JSON.stringify(json)); +const jsonToBase64 = (json) => { + const bytes = Buffer.from(JSON.stringify(json)); - return bytes - .toString('base64') - .replace(/\+/g, '-') - .replace(/\//g, '_') - .replace(/=+$/, ''); + return bytes.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); }; /** - * Simple wrapper that, given a class, a property name and a method name, - * creates a new method in the class that is a wrapper for the given - * property method. + * Return an object with information about the current client. * - * @method wrapPropertyMethod - * @memberOf module:utils + * @function generateClientInfo + * @returns {object} Object containing client information. */ -utils.wrapPropertyMethod = function(Parent, name, propertyMethod) { - var path = propertyMethod.split('.'); - var property = path.shift(); - var method = path.pop(); +const generateClientInfo = () => ({ + name: 'node-auth0', + version: pkg.version, + env: { + node: process.version.replace('v', ''), + }, +}); - Object.defineProperty(Parent.prototype, name, { - enumerable: false, - get: function() { - return this[property][method].bind(this[property]); - } - }); +const containsUnsafeChars = (s) => { + const safeChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*'(),%"; + return !!s.split('').find((c) => !safeChars.includes(c)); }; -/** - * Perform a request with the given settings and return a promise that resolves - * when the request is successfull and rejects when there's an error. - * - * @method getRequestPromise - * @memberOf module:utils - */ -utils.getRequestPromise = function(settings) { - return new Promise(function(resolve, reject) { - request( - { - url: settings.url, - method: settings.method, - body: settings.data, - json: typeof settings.data === 'object', - headers: settings.headers - }, - function(err, res, body) { - if (err) { - reject(err); - return; - } +const maybeDecode = (url) => { + if (containsUnsafeChars(url)) { + return encodeURIComponent(url); + } + return url; +}; + +const sanitizeArguments = function (optionsCandidate, cbCandidate) { + if (optionsCandidate instanceof Function) { + return { + cb: optionsCandidate, + options: undefined, + }; + } + return { + cb: cbCandidate, + options: optionsCandidate, + }; +}; - resolve(res.body); - } - ); - }); +module.exports = { + jsonToBase64, + generateClientInfo, + containsUnsafeChars, + maybeDecode, + sanitizeArguments, }; diff --git a/test/auth/authentication-client.tests.js b/test/auth/authentication-client.tests.js index edb873936..dd97adcdc 100644 --- a/test/auth/authentication-client.tests.js +++ b/test/auth/authentication-client.tests.js @@ -1,79 +1,225 @@ -var expect = require('chai').expect; +const { expect } = require('chai'); +const sinon = require('sinon'); +const proxyquire = require('proxyquire'); -var ArgumentError = require('rest-facade').ArgumentError; +const { ArgumentError } = require('rest-facade'); -var AuthenticationClient = require('../../src/auth'); -var OAuthAuthenticator = require('../../src/auth/OAuthAuthenticator'); -var DatabaseAuthenticator = require('../../src/auth/DatabaseAuthenticator'); -var PasswordlessAuthenticator = require('../../src/auth/PasswordlessAuthenticator'); -var UsersManager = require('../../src/auth/UsersManager'); -var TokensManager = require('../../src/auth/TokensManager'); +const AuthenticationClient = require('../../src/auth'); +const OAuthAuthenticator = require('../../src/auth/OAuthAuthenticator'); +const DatabaseAuthenticator = require('../../src/auth/DatabaseAuthenticator'); +const PasswordlessAuthenticator = require('../../src/auth/PasswordlessAuthenticator'); +const UsersManager = require('../../src/auth/UsersManager'); +const TokensManager = require('../../src/auth/TokensManager'); -var ensureProperty = require('../utils').ensureProperty; +const { ensureProperty } = require('../utils'); -describe('AuthenticationClient', function() { - describe('#constructor', function() { - it('should raise an error when no options object is provided', function() { - expect(AuthenticationClient).to.throw( - ArgumentError, - 'Authentication Client SDK options must be an object' - ); +describe('AuthenticationClient', () => { + describe('#constructor', () => { + it('should raise an error when no options object is provided', () => { + expect(() => { + new AuthenticationClient(); + }).to.throw(ArgumentError, 'Authentication Client SDK options must be an object'); }); - it('should raise an error when the domain is not valid', function() { - var client = AuthenticationClient.bind(null, { token: 'token', domain: '' }); - - expect(client).to.throw(ArgumentError, 'Must provide a domain'); + it('should raise an error when the domain is not valid', () => { + expect(() => { + new AuthenticationClient({ token: 'token', domain: '' }); + }).to.throw(ArgumentError, 'Must provide a domain'); }); }); - describe('instance properties', function() { - var properties = { + describe('instance properties', () => { + const properties = { OAuthAuthenticator: { name: 'oauth', - cls: OAuthAuthenticator + cls: OAuthAuthenticator, }, DatabaseAuthenticator: { name: 'database', - cls: DatabaseAuthenticator + cls: DatabaseAuthenticator, }, PasswordlessAuthenticator: { name: 'passwordless', - cls: PasswordlessAuthenticator + cls: PasswordlessAuthenticator, }, UsersManager: { name: 'users', - cls: UsersManager + cls: UsersManager, }, TokensManager: { name: 'tokens', - cls: TokensManager - } + cls: TokensManager, + }, }; - var options = { + const options = { clientId: 'CLIENT_ID', - domain: 'tenant.auth0.com' + domain: 'tenant.auth0.com', }; - var client = new AuthenticationClient(options); + const client = new AuthenticationClient(options); // Tests common to all properties. - for (var name in properties) { - var property = properties[name]; + for (const name in properties) { + const property = properties[name]; it( - 'should expose an instance of ' + name, + `should expose an instance of ${name}`, ensureProperty(client, property.name, property.cls) ); } }); - describe('instance methods', function() { - var method; - var methods = []; - var client = new AuthenticationClient({ token: 'token', domain: 'auth0.com' }); + describe('client info', () => { + it('should configure instances with default telemetry header', () => { + const utilsStub = { + generateClientInfo: sinon.spy(() => ({ name: 'test-sdk', version: 'ver-123' })), + }; + const AuthenticationClientProxy = proxyquire('../../src/auth/', { + '../utils': utilsStub, + }); + + const client = new AuthenticationClientProxy({ token: 'token', domain: 'auth0.com' }); + + const requestHeaders = { + 'Auth0-Client': 'eyJuYW1lIjoidGVzdC1zZGsiLCJ2ZXJzaW9uIjoidmVyLTEyMyJ9', + 'Content-Type': 'application/json', + }; + expect(client.oauth.oauth.options.headers).to.contain(requestHeaders); + expect(client.database.dbConnections.options.headers).to.contain(requestHeaders); + expect(client.passwordless.passwordless.options.headers).to.contain(requestHeaders); + expect(client.users.headers).to.contain(requestHeaders); + expect(client.tokens.headers).to.contain(requestHeaders); + }); + + it('should configure instances with custom telemetry header', () => { + const customTelemetry = { name: 'custom', version: 'beta-01', env: { node: 'v10' } }; + const client = new AuthenticationClient({ + token: 'token', + domain: 'auth0.com', + clientInfo: customTelemetry, + }); + + const requestHeaders = { + 'Auth0-Client': + 'eyJuYW1lIjoiY3VzdG9tIiwidmVyc2lvbiI6ImJldGEtMDEiLCJlbnYiOnsibm9kZSI6InYxMCJ9fQ', + 'Content-Type': 'application/json', + }; + expect(client.oauth.oauth.options.headers).to.contain(requestHeaders); + expect(client.database.dbConnections.options.headers).to.contain(requestHeaders); + expect(client.passwordless.passwordless.options.headers).to.contain(requestHeaders); + expect(client.users.headers).to.contain(requestHeaders); + expect(client.tokens.headers).to.contain(requestHeaders); + }); + + it('should configure instances without telemetry when "name" property is empty', () => { + const customTelemetry = { name: '', version: 'beta-01', env: { node: 'v10' } }; + const client = new AuthenticationClient({ + token: 'token', + domain: 'auth0.com', + clientInfo: customTelemetry, + }); + + expect(client.oauth.oauth.options.headers).to.not.have.property('Auth0-Client'); + expect(client.database.dbConnections.options.headers).to.not.have.property('Auth0-Client'); + expect(client.passwordless.passwordless.options.headers).to.not.have.property('Auth0-Client'); + expect(client.users.headers).to.not.have.property('Auth0-Client'); + expect(client.tokens.headers).to.not.have.property('Auth0-Client'); + }); + + it('should configure instances without telemetry header when disabled', () => { + const client = new AuthenticationClient({ + token: 'token', + domain: 'auth0.com', + telemetry: false, + }); + + expect(client.oauth.oauth.options.headers).to.not.have.property('Auth0-Client'); + expect(client.database.dbConnections.options.headers).to.not.have.property('Auth0-Client'); + expect(client.passwordless.passwordless.options.headers).to.not.have.property('Auth0-Client'); + expect(client.users.headers).to.not.have.property('Auth0-Client'); + expect(client.tokens.headers).to.not.have.property('Auth0-Client'); + }); + }); + + describe('user agent', () => { + it('should use the node version when the user agent option is not provided', () => { + const client = new AuthenticationClient({ + token: 'token', + domain: 'auth0.com', + }); - methods.forEach(function(method) { - ensureMethod(client, method); + const expected = { 'User-Agent': `node.js/${process.version.replace('v', '')}` }; + + expect(client.oauth.oauth.options.headers).to.contain(expected); + expect(client.database.dbConnections.options.headers).to.contain(expected); + expect(client.passwordless.passwordless.options.headers).to.contain(expected); + expect(client.users.headers).to.contain(expected); + expect(client.tokens.headers).to.contain(expected); + }); + + it('should include additional headers when provided', () => { + const customHeaders = { + 'User-Agent': 'my-user-agent', + 'Another-header': 'test-header', + }; + + const client = new AuthenticationClient({ + token: 'token', + domain: 'auth0.com', + headers: customHeaders, + }); + + expect(client.oauth.oauth.options.headers).to.contain(customHeaders); + expect(client.database.dbConnections.options.headers).to.contain(customHeaders); + expect(client.passwordless.passwordless.options.headers).to.contain(customHeaders); + expect(client.users.headers).to.contain(customHeaders); + expect(client.tokens.headers).to.contain(customHeaders); + }); + }); + + describe(`verifySMSCode`, () => { + before(function () { + this.client = new AuthenticationClient({ token: 'token', domain: 'auth0.com' }); + this.passwordlessMock = sinon.mock(this.client.passwordless); + this.callback = function () {}; + }); + it('should call signIn with otp if provided', function () { + this.passwordlessMock.expects('signIn').once().withExactArgs( + { + username: '123', + otp: 'code', + }, + this.callback + ); + this.client.verifySMSCode({ phone_number: '123', otp: 'code' }, this.callback); + }); + it('should call signIn with password if provided', function () { + this.passwordlessMock.expects('signIn').once().withExactArgs( + { + username: '123', + password: 'code', + }, + this.callback + ); + this.client.verifySMSCode({ phone_number: '123', password: 'code' }, this.callback); + }); + }); + + describe(`verifyEmailCode`, () => { + before(function () { + this.client = new AuthenticationClient({ token: 'token', domain: 'auth0.com' }); + this.passwordlessMock = sinon.mock(this.client.passwordless); + this.callback = function () {}; + }); + it('should call signIn with otp if provided', function () { + this.passwordlessMock.expects('signIn').once().withExactArgs( + { + username: '123', + realm: 'email', + otp: 'code', + }, + this.callback + ); + this.client.verifyEmailCode({ email: '123', otp: 'code' }, this.callback); }); }); }); diff --git a/test/auth/database-auth.tests.js b/test/auth/database-auth.tests.js index d54b07167..c1bfb82a5 100644 --- a/test/auth/database-auth.tests.js +++ b/test/auth/database-auth.tests.js @@ -1,117 +1,106 @@ -var expect = require('chai').expect; -var extend = require('util')._extend; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -// Constants. -var SRC_DIR = '../../src'; -var DOMAIN = 'tenant.auth0.com'; -var API_URL = 'https://' + DOMAIN; -var CLIENT_ID = 'TEST_CLIENT_ID'; +const DOMAIN = 'tenant.auth0.com'; +const API_URL = `https://${DOMAIN}`; +const CLIENT_ID = 'TEST_CLIENT_ID'; -var ArgumentError = require('rest-facade').ArgumentError; -var Authenticator = require(SRC_DIR + '/auth/DatabaseAuthenticator'); -var OAuth = require(SRC_DIR + '/auth/OAuthAuthenticator'); +const { ArgumentError } = require('rest-facade'); +const DatabaseAuthenticator = require(`../../src/auth/DatabaseAuthenticator`); +const OAuth = require(`../../src/auth/OAuthAuthenticator`); -var validOptions = { +const validOptions = { baseUrl: API_URL, - clientId: CLIENT_ID + clientId: CLIENT_ID, }; -describe('DatabaseAuthenticator', function() { - afterEach(function() { +describe('DatabaseAuthenticator', () => { + afterEach(() => { nock.cleanAll(); }); - describe('#constructor', function() { - it('should require an options object', function() { - expect(Authenticator).to.throw(ArgumentError, 'Missing authenticator options'); + describe('#constructor', () => { + it('should require an options object', () => { + expect(() => { + new DatabaseAuthenticator(); + }).to.throw(ArgumentError, 'Missing authenticator options'); - expect(Authenticator.bind(null, 1)).to.throw( - ArgumentError, - 'The authenticator options must be an object' - ); + expect(() => { + new DatabaseAuthenticator(1); + }).to.throw(ArgumentError, 'The authenticator options must be an object'); - expect(Authenticator.bind(null, validOptions)).to.not.throw(ArgumentError); + expect(() => { + new DatabaseAuthenticator(validOptions); + }).to.not.throw(ArgumentError); }); }); - describe('instance', function() { - var methods = ['signIn', 'signUp', 'changePassword', 'requestChangePasswordEmail']; - var oauth = new OAuth(validOptions); - var authenticator = new Authenticator(validOptions, oauth); + describe('instance', () => { + const methods = ['signIn', 'signUp', 'changePassword', 'requestChangePasswordEmail']; + const oauth = new OAuth(validOptions); + const authenticator = new DatabaseAuthenticator(validOptions, oauth); - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, () => { expect(authenticator[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#signIn', function() { - var path = '/oauth/ro'; - var userData = { + describe('#signIn', () => { + const path = '/oauth/ro'; + const userData = { username: 'username', - password: 'pwd' + password: 'pwd', }; - beforeEach(function() { - var oauth = new OAuth(validOptions); - this.authenticator = new Authenticator(validOptions, oauth); - this.request = nock(API_URL) - .post(path) - .reply(200); + beforeEach(function () { + const oauth = new OAuth(validOptions); + this.authenticator = new DatabaseAuthenticator(validOptions, oauth); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { + it('should require an object as first argument', function () { expect(this.authenticator.signIn).to.throw(ArgumentError, 'Missing user data object'); }); - it('should require a username', function() { - var auth = this.authenticator; - var userData = { password: 'password' }; - var signIn = auth.signIn.bind(auth, userData); + it('should require a username', function () { + const auth = this.authenticator; + const userData = { password: 'password' }; + const signIn = auth.signIn.bind(auth, userData); expect(signIn).to.throw(ArgumentError, 'username field is required'); }); - it('should require a password', function() { - var auth = this.authenticator; - var userData = { username: 'username' }; - var signIn = auth.signIn.bind(auth, userData); + it('should require a password', function () { + const auth = this.authenticator; + const userData = { username: 'username' }; + const signIn = auth.signIn.bind(auth, userData); expect(signIn).to.throw(ArgumentError, 'password field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.signIn(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { - this.authenticator - .signIn(userData) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise when no callback is provided', function () { + expect(this.authenticator.signIn(userData)).instanceOf(Promise); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, async function () { + const { request } = this; - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signIn(userData); + expect(request.isDone()).to.be.true; }); - it('should include the user data in the request', function(done) { + it('should include the user data in the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -121,206 +110,146 @@ describe('DatabaseAuthenticator', function() { }) .reply(200); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signIn(userData); + expect(request.isDone()).to.be.true; }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signIn(userData); + expect(request.isDone()).to.be.true; }); - it('should use Username-Password-Authentication by default', function(done) { + it('should use Username-Password-Authentication by default', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'Username-Password-Authentication'; - }) + const request = nock(API_URL) + .post(path, (body) => body.connection === 'Username-Password-Authentication') .reply(200); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signIn(userData); + expect(request.isDone()).to.be.true; }); - it('should allow the user to specify the connection', function(done) { + it('should allow the user to specify the connection', async function () { nock.cleanAll(); - var data = extend({ connection: 'TEST_CONNECTION' }, userData); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'TEST_CONNECTION'; - }) + const data = { connection: 'TEST_CONNECTION', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.connection === 'TEST_CONNECTION') .reply(200); - this.authenticator - .signIn(data) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signIn(data); + expect(request.isDone()).to.be.true; }); - it('should use password as default grant type', function(done) { + it('should use password as default grant type', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'password'; - }) + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'password') .reply(200); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signIn(userData); + expect(request.isDone()).to.be.true; }); - it('should allow the user to specify the grant type', function(done) { + it('should allow the user to specify the grant type', async function () { nock.cleanAll(); - var data = extend({ grant_type: 'TEST_GRANT' }, userData); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'TEST_GRANT'; - }) + const data = { grant_type: 'TEST_GRANT', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'TEST_GRANT') .reply(200); - this.authenticator - .signIn(data) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signIn(data); + expect(request.isDone()).to.be.true; }); - it('should use the openid scope by default', function(done) { + it('should use the openid scope by default', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.scope === 'openid'; - }) + const request = nock(API_URL) + .post(path, (body) => body.scope === 'openid') .reply(200); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signIn(userData); + expect(request.isDone()).to.be.true; }); }); - describe('#signUp', function() { - var path = '/dbconnections/signup'; - var userData = { + describe('#signUp', () => { + const path = '/dbconnections/signup'; + const userData = { email: 'test@domain.com', password: 'pwd', - connection: 'TEST_CONNECTION' + connection: 'TEST_CONNECTION', }; - beforeEach(function() { - this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + beforeEach(function () { + this.authenticator = new DatabaseAuthenticator(validOptions); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { - expect(this.authenticator.signUp).to.throw(ArgumentError, 'Missing user data object'); + it('should require an object as first argument', function () { + expect(() => { + this.authenticator.signUp(); + }).to.throw(ArgumentError, 'Missing user data object'); }); - it('should require an email', function() { - var auth = this.authenticator; - var userData = { password: 'password' }; - var signUp = auth.signUp.bind(auth, userData); + it('should require an email', function () { + const auth = this.authenticator; + const userData = { password: 'password' }; + const signUp = auth.signUp.bind(auth, userData); - expect(signUp).to.throw(ArgumentError, 'email field is required'); + expect(() => { + signUp(); + }).to.throw(ArgumentError, 'email field is required'); }); - it('should require a password', function() { - var auth = this.authenticator; - var userData = { email: 'email@domain.com' }; - var signUp = auth.signUp.bind(auth, userData); + it('should require a password', function () { + const auth = this.authenticator; + const userData = { email: 'email@domain.com' }; + const signUp = auth.signUp.bind(auth, userData); expect(signUp).to.throw(ArgumentError, 'password field is required'); }); - it('should require a connection', function() { - var auth = this.authenticator; - var userData = { email: 'email@domain.com', password: 'test' }; - var signUp = auth.signUp.bind(auth, userData); + it('should require a connection', function () { + const auth = this.authenticator; + const userData = { email: 'email@domain.com', password: 'test' }; - expect(signUp).to.throw(ArgumentError, 'connection field is required'); + expect(() => { + auth.signUp(userData); + }).to.throw(ArgumentError, 'connection field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.signUp(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { - this.authenticator - .signUp(userData) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise when no callback is provided', function (done) { + this.authenticator.signUp(userData).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, async function () { + const { request } = this; - this.authenticator - .signUp(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signUp(userData); + expect(request.isDone()).to.be.true; }); - it('should include the user data in the request', function(done) { + it('should include the user data in the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -330,109 +259,92 @@ describe('DatabaseAuthenticator', function() { }) .reply(200); - this.authenticator - .signUp(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signUp(userData); + expect(request.isDone()).to.be.true; }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); - this.authenticator - .signUp(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.signUp(userData); + expect(request.isDone()).to.be.true; }); }); - describe('#changePassword', function() { - var path = '/dbconnections/change_password'; - var userData = { + describe('#changePassword', () => { + const path = '/dbconnections/change_password'; + const userData = { email: 'test@domain.com', password: 'newPwd', - connection: 'TEST_CONNECTION' + connection: 'TEST_CONNECTION', }; - beforeEach(function() { - this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + beforeEach(function () { + this.authenticator = new DatabaseAuthenticator(validOptions); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { - expect(this.authenticator.changePassword).to.throw(ArgumentError, 'Missing user data object'); + it('should require an object as first argument', function () { + expect(() => { + this.authenticator.changePassword(); + }).to.throw(ArgumentError, 'Missing user data object'); }); - it('should require an email', function() { - var auth = this.authenticator; - var userData = { password: 'password' }; - var changePassword = auth.changePassword.bind(auth, userData); + it('should require an email', function () { + const auth = this.authenticator; + const userData = { password: 'password' }; - expect(changePassword).to.throw(ArgumentError, 'email field is required'); + expect(() => { + auth.changePassword(userData); + }).to.throw(ArgumentError, 'email field is required'); }); - it('should require a password', function() { - var auth = this.authenticator; - var userData = { email: 'email@domain.com' }; - var changePassword = auth.changePassword.bind(auth, userData); + it('should require a password', function () { + const auth = this.authenticator; + const userData = { email: 'email@domain.com' }; - expect(changePassword).to.throw(ArgumentError, 'password field is required'); + expect(() => { + auth.changePassword(userData); + }).to.throw(ArgumentError, 'password field is required'); }); - it('should require a connection', function() { - var auth = this.authenticator; - var userData = { email: 'email@domain.com', password: 'test' }; - var changePassword = auth.changePassword.bind(auth, userData); + it('should require a connection', function () { + const auth = this.authenticator; + const userData = { email: 'email@domain.com', password: 'test' }; - expect(changePassword).to.throw(ArgumentError, 'connection field is required'); + expect(() => { + auth.changePassword(userData); + }).to.throw(ArgumentError, 'connection field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.changePassword(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { + it('should return a promise when no callback is provided', function (done) { this.authenticator .changePassword(userData) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, async function () { + const { request } = this; - this.authenticator - .changePassword(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.changePassword(userData); + expect(request.isDone()).to.be.true; }); - it('should include the user data in the request', function(done) { + it('should include the user data in the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -442,103 +354,79 @@ describe('DatabaseAuthenticator', function() { }) .reply(200); - this.authenticator - .changePassword(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.changePassword(userData); + expect(request.isDone()).to.be.true; }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); - this.authenticator - .changePassword(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.changePassword(userData); + expect(request.isDone()).to.be.true; }); }); - describe('#requestChangePasswordEmail', function() { - var path = '/dbconnections/change_password'; - var userData = { + describe('#requestChangePasswordEmail', () => { + const path = '/dbconnections/change_password'; + const userData = { email: 'test@domain.com', - connection: 'TEST_CONNECTION' + connection: 'TEST_CONNECTION', }; - beforeEach(function() { - this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + beforeEach(function () { + this.authenticator = new DatabaseAuthenticator(validOptions); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { - expect(this.authenticator.requestChangePasswordEmail).to.throw( - ArgumentError, - 'Missing user data object' - ); + it('should require an object as first argument', function () { + expect(() => { + this.authenticator.requestChangePasswordEmail(); + }).to.throw(ArgumentError, 'Missing user data object'); }); - it('should require an email', function() { - var auth = this.authenticator; - var userData = {}; - var requestChangePasswordEmail = auth.requestChangePasswordEmail.bind(auth, userData); - - expect(requestChangePasswordEmail).to.throw(ArgumentError, 'email field is required'); + it('should require an email', function () { + expect(() => { + this.authenticator.requestChangePasswordEmail({}); + }).to.throw(ArgumentError, 'email field is required'); }); - it('should require a connection', function() { - var auth = this.authenticator; - var userData = { email: 'email@domain.com' }; - var requestChangePasswordEmail = auth.requestChangePasswordEmail.bind(auth, userData); + it('should require a connection', function () { + const auth = this.authenticator; + const userData = { email: 'email@domain.com' }; - expect(requestChangePasswordEmail).to.throw(ArgumentError, 'connection field is required'); + expect(() => { + auth.requestChangePasswordEmail(userData); + }).to.throw(ArgumentError, 'connection field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.requestChangePasswordEmail(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { + it('should return a promise when no callback is provided', function (done) { this.authenticator .requestChangePasswordEmail(userData) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, async function () { + const { request } = this; - this.authenticator - .requestChangePasswordEmail(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.requestChangePasswordEmail(userData); + expect(request.isDone()).to.be.true; }); - it('should include the user data in the request', function(done) { + it('should include the user data in the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -548,33 +436,19 @@ describe('DatabaseAuthenticator', function() { }) .reply(200); - this.authenticator - .requestChangePasswordEmail(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.requestChangePasswordEmail(userData); + expect(request.isDone()).to.be.true; }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); - this.authenticator - .requestChangePasswordEmail(userData) - .then(function() { - expect(request.isDone()).to.be.true; - - done(); - }) - .catch(done); + await this.authenticator.requestChangePasswordEmail(userData); + expect(request.isDone()).to.be.true; }); }); }); diff --git a/test/auth/oauth-with-idtoken-validation.tests.js b/test/auth/oauth-with-idtoken-validation.tests.js index 8e53a2490..0ad232939 100644 --- a/test/auth/oauth-with-idtoken-validation.tests.js +++ b/test/auth/oauth-with-idtoken-validation.tests.js @@ -1,55 +1,50 @@ -var expect = require('chai').expect; -var Promise = require('bluebird'); -var sinon = require('sinon'); -var proxyquire = require('proxyquire'); - -var jwt = require('jsonwebtoken'); -var jwksClient = require('jwks-rsa'); -var pem = require('pem'); +const { expect } = require('chai'); +const sinon = require('sinon'); +const proxyquire = require('proxyquire'); +const jwt = require('jsonwebtoken'); +const jwksClient = require('jwks-rsa'); +const crypto = require('crypto'); // Constants. -var DOMAIN = 'tenant.auth0.com'; -var CLIENT_ID = 'TEST_CLIENT_ID'; -var CLIENT_SECRET = new Buffer('TEST_CLIENT_SECRET', 'base64'); - -var OAUthWithIDTokenValidation = require('../../src/auth/OAUthWithIDTokenValidation'); -var PARAMS = { params: true }; -var DATA = { data: true }; - -var createCertificate = function(cb) { - pem.createCertificate({ days: 1, selfSigned: true }, function(err, keys) { - if (err) { - throw err; - } - pem.getPublicKey(keys.certificate, function(e, p) { - if (e) { - throw e; - } - cb({ serviceKey: keys.serviceKey, certificate: keys.certificate, publicKey: p.publicKey }); - }); +const DOMAIN = 'tenant.auth0.com'; +const CLIENT_ID = 'TEST_CLIENT_ID'; +const CLIENT_SECRET = Buffer.from('TEST_CLIENT_SECRET', 'base64'); + +const OAUthWithIDTokenValidation = require('../../src/auth/OAUthWithIDTokenValidation'); +const PARAMS = { params: true }; +const DATA = { data: true }; + +const createCertificate = function (cb) { + const { publicKey: pubRsaKey, privateKey: privRsaKey } = crypto.generateKeyPairSync('rsa', { + modulusLength: 2048, }); + + const publicKey = pubRsaKey.export({ type: 'spki', format: 'pem' }); + const serviceKey = privRsaKey.export({ type: 'pkcs8', format: 'pem' }); + + cb({ serviceKey, publicKey }); }; -describe('OAUthWithIDTokenValidation', function() { - describe('constructor', function() { - it('validates `oauth` is required', function() { - expect(function() { +describe('OAUthWithIDTokenValidation', () => { + describe('constructor', () => { + it('validates `oauth` is required', () => { + expect(() => { new OAUthWithIDTokenValidation(); }).to.throw('Missing OAuthAuthenticator param'); }); - it('validates `options` is required', function() { - expect(function() { + it('validates `options` is required', () => { + expect(() => { new OAUthWithIDTokenValidation({}); }).to.throw('Missing authenticator options'); }); - it('validates `oauth` is required', function() { - expect(function() { + it('validates `oauth` is required', () => { + expect(() => { new OAUthWithIDTokenValidation({}, 'asd'); }).to.throw('The authenticator options must be an object'); }); }); - describe('#create', function() { - this.afterEach(function() { + describe('#create', function () { + this.afterEach(() => { if (jwt.verify.restore) { jwt.verify.restore(); } @@ -57,389 +52,498 @@ describe('OAUthWithIDTokenValidation', function() { jwksClient.restore(); } }); - it('Calls `oauth.create` with correct params', function(done) { - var oauth = { - create: function(params, data) { + it('Calls `oauth.create` with correct params', (done) => { + const oauth = { + create(params, data) { expect(params).to.be.equal(PARAMS); expect(data).to.be.equal(DATA); - return new Promise(res => res({})); - } + done(); + }, + }; + const oauthWithValidation = new OAUthWithIDTokenValidation(oauth, {}); + oauthWithValidation.create(PARAMS, DATA); + }); + it('Does nothing when there is no id_token', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({})); + }, }; - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, {}); + const oauthWithValidation = new OAUthWithIDTokenValidation(oauth, {}); oauthWithValidation.create(PARAMS, DATA, done); }); - it('Does nothing when there is no id_token', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({})); - } + it('Bypasses validation when options.__bypassIdTokenValidation is true', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, {}); + const oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { + __bypassIdTokenValidation: true, + }); oauthWithValidation.create(PARAMS, DATA, done); }); - it('Calls jwt.verify with token and algs', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } + it('Calls jwt.verify with token and algs', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey, options) => { expect(idtoken).to.be.equal('foobar'); expect(options).to.be.eql({ audience: CLIENT_ID, algorithms: ['HS256', 'RS256'], - issuer: 'https://' + DOMAIN + '/' + issuer: `https://${DOMAIN}/`, }); done(); }); - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { + const oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { clientId: CLIENT_ID, - domain: DOMAIN + domain: DOMAIN, }); oauthWithValidation.create(PARAMS, DATA); }); - it('Returns auth result when verify response is successful', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } + it('Returns auth result when verify response is successful', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey, options, callback) => { callback(null, { verification: 'result' }); }); - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, {}); - oauthWithValidation.create(PARAMS, DATA).then(function(r) { + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + './idToken': { validate: (token) => token }, + } + ); + + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, {}); + oauthWithValidation.create(PARAMS, DATA).then((r) => { expect(r).to.be.eql({ id_token: 'foobar' }); done(); }); }); - it('Returns error when verify response is an error', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } + + it('Returns error when verify response is an error', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey, options, callback) => { callback({ the: 'error' }); }); - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, {}); - oauthWithValidation.create(PARAMS, DATA).catch(function(r) { + const oauthWithValidation = new OAUthWithIDTokenValidation(oauth, {}); + oauthWithValidation.create(PARAMS, DATA).catch((r) => { expect(r).to.be.eql({ the: 'error' }); done(); }); }); - it('Calls uses secret as key when header.alg === HS256', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } + + it('Uses `clientSecret` as key when header.alg === HS256 and there is a user secret', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { - getKey({ alg: 'HS256' }, function(err, key) { + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey) => { + getKey({ alg: 'HS256' }, (err, key) => { expect(key).to.be.eql(Buffer.from(CLIENT_SECRET, 'base64')); done(); }); }); - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { - clientSecret: CLIENT_SECRET + const oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { + clientSecret: CLIENT_SECRET, }); oauthWithValidation.create(PARAMS, DATA); }); - describe('when header.alg !== HS256', function() { - it('creates a jwksClient with the correct jwksUri', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } - }; - var jwksClientStub = sinon.spy(function() { - return { - getSigningKey: function(kid, cb) { - cb(null, { publicKey: 'publicKey' }); - } - }; - }); - OAUthWithIDTokenValidationProxy = proxyquire('../../src/auth/OAUthWithIDTokenValidation', { - 'jwks-rsa': jwksClientStub + it('Returns unvalidated response when header.alg === HS256 and there is no user secret', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, + }; + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + './idToken': { validate: (token) => token }, + } + ); + + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey, options, callback) => { + getKey({ alg: 'HS256' }, (err, key) => { + expect(err.message).to.contain( + 'Validation of `id_token` requires a `clientSecret` when using the HS256 algorithm. To ensure tokens are validated, please switch the signing algorithm to RS256 or provide a `clientSecret` in the constructor.' + ); + callback(err, key); }); + }); + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, {}); + oauthWithValidation.create(PARAMS, DATA, (err, response) => { + expect(err).to.be.null; + expect(response).to.be.eql({ id_token: 'foobar' }); + done(); + }); + }); + + describe('when header.alg !== HS256', () => { + it('creates a jwksClient with the correct jwksUri', (done) => { + const oauth = { + create: () => new Promise((resolve) => resolve({ id_token: 'foobar' })), + }; + + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + cb(null, { publicKey: 'publicKey' }); + }, + })); + jwksClientStub.prototype = {}; - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { - getKey({ alg: 'RS256' }, function(err, key) { + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + 'jwks-rsa': jwksClientStub, + } + ); + + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey) => { + getKey({ alg: 'RS256' }, () => { expect(jwksClientStub.getCall(0).args[0].jwksUri).to.be.equal( 'https://tenant.auth0.com/.well-known/jwks.json' ); done(); }); }); - var oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { domain: DOMAIN, - clientSecret: CLIENT_SECRET + clientSecret: CLIENT_SECRET, }); oauthWithValidation.create(PARAMS, DATA); }); - it('returns the error when available', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } + + it('returns the error when available', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - var jwksClientStub = sinon.spy(function() { - return { - getSigningKey: function(kid, cb) { - cb({ the: 'error' }); - } - }; - }); - OAUthWithIDTokenValidationProxy = proxyquire('../../src/auth/OAUthWithIDTokenValidation', { - 'jwks-rsa': jwksClientStub - }); + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + cb({ the: 'error' }); + }, + })); + jwksClientStub.prototype = {}; + + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + 'jwks-rsa': jwksClientStub, + } + ); - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { - getKey({ kid: 'kid', alg: 'RS256' }, function(err, key) { + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey) => { + getKey({ kid: 'kid', alg: 'RS256' }, (err) => { expect(err).to.be.eql({ the: 'error' }); done(); }); }); - var oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { domain: DOMAIN, - clientSecret: CLIENT_SECRET + clientSecret: CLIENT_SECRET, }); oauthWithValidation.create(PARAMS, DATA); }); - it('uses the publicKey when available', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } + + it('uses the publicKey when available', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - var jwksClientStub = sinon.spy(function() { - return { - getSigningKey: function(kid, cb) { - expect(kid).to.be.equal('kid'); - cb(null, { publicKey: 'publicKey' }); - } - }; - }); - OAUthWithIDTokenValidationProxy = proxyquire('../../src/auth/OAUthWithIDTokenValidation', { - 'jwks-rsa': jwksClientStub - }); + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + expect(kid).to.be.equal('kid'); + cb(null, { publicKey: 'publicKey' }); + }, + })); + jwksClientStub.prototype = {}; + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + 'jwks-rsa': jwksClientStub, + } + ); - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { - getKey({ kid: 'kid', alg: 'RS256' }, function(err, key) { + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey) => { + getKey({ kid: 'kid', alg: 'RS256' }, (err, key) => { expect(key).to.be.equal('publicKey'); done(); }); }); - var oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { domain: DOMAIN, - clientSecret: CLIENT_SECRET + clientSecret: CLIENT_SECRET, }); oauthWithValidation.create(PARAMS, DATA); }); - it('uses the publicKey when both keys (publicKey and rsaPublicKey) available', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } + + it('uses the publicKey when both keys (publicKey and rsaPublicKey) available', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - var jwksClientStub = sinon.spy(function() { - return { - getSigningKey: function(kid, cb) { - expect(kid).to.be.equal('kid'); - cb(null, { publicKey: 'publicKey', rsaPublicKey: 'rsaPublicKey' }); - } - }; - }); - OAUthWithIDTokenValidationProxy = proxyquire('../../src/auth/OAUthWithIDTokenValidation', { - 'jwks-rsa': jwksClientStub - }); + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + expect(kid).to.be.equal('kid'); + cb(null, { publicKey: 'publicKey', rsaPublicKey: 'rsaPublicKey' }); + }, + })); + jwksClientStub.prototype = {}; + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + 'jwks-rsa': jwksClientStub, + } + ); - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { - getKey({ kid: 'kid', alg: 'RS256' }, function(err, key) { + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey) => { + getKey({ kid: 'kid', alg: 'RS256' }, (err, key) => { expect(key).to.be.equal('publicKey'); done(); }); }); - var oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { domain: DOMAIN, - clientSecret: CLIENT_SECRET + clientSecret: CLIENT_SECRET, }); oauthWithValidation.create(PARAMS, DATA); }); - it('uses the rsaPublicKey when there is no publicKey available', function(done) { - var oauth = { - create: function() { - return new Promise(res => res({ id_token: 'foobar' })); - } + + it('uses the rsaPublicKey when there is no publicKey available', (done) => { + const oauth = { + create() { + return new Promise((resolve) => resolve({ id_token: 'foobar' })); + }, }; - var jwksClientStub = sinon.spy(function() { - return { - getSigningKey: function(kid, cb) { - expect(kid).to.be.equal('kid'); - cb(null, { rsaPublicKey: 'rsaPublicKey' }); - } - }; - }); - OAUthWithIDTokenValidationProxy = proxyquire('../../src/auth/OAUthWithIDTokenValidation', { - 'jwks-rsa': jwksClientStub - }); + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + expect(kid).to.be.equal('kid'); + cb(null, { rsaPublicKey: 'rsaPublicKey' }); + }, + })); + jwksClientStub.prototype = {}; + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + 'jwks-rsa': jwksClientStub, + } + ); - sinon.stub(jwt, 'verify', function(idtoken, getKey, options, callback) { - getKey({ kid: 'kid', alg: 'RS256' }, function(err, key) { + sinon.stub(jwt, 'verify').callsFake((idtoken, getKey) => { + getKey({ kid: 'kid', alg: 'RS256' }, (err, key) => { expect(key).to.be.equal('rsaPublicKey'); done(); }); }); - var oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { domain: DOMAIN, - clientSecret: CLIENT_SECRET + clientSecret: CLIENT_SECRET, }); oauthWithValidation.create(PARAMS, DATA); }); }); - describe('#integration', function() { - it('fails with a HS256 id_token and `options.supportedAlgorithms===RS256`', done => { - var oauth = { - create: function() { - return new Promise(res => - res({ + + describe('#integration', () => { + it('fails with a HS256 id_token and `options.supportedAlgorithms===RS256`', (done) => { + const oauth = { + create() { + return new Promise((resolve) => + resolve({ id_token: - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuaWNrbmFtZSI6ImpvaG5mb28iLCJuYW1lIjoiam9obmZvb0BnbWFpbC5jb20iLCJwaWN0dXJlIjoiaHR0cHM6Ly9zLmdyYXZhdGFyLmNvbS9hdmF0YXIvMzhmYTAwMjQyM2JkOGM5NDFjNmVkMDU4OGI2MGZmZWQ_cz00ODAmcj1wZyZkPWh0dHBzJTNBJTJGJTJGY2RuLmF1dGgwLmNvbSUyRmF2YXRhcnMlMkZqby5wbmciLCJ1cGRhdGVkX2F0IjoiMjAxOC0wOS0xMlQyMDo1MjoxMS4zMDZaIiwiZW1haWwiOiJqb2huZm9vQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiaXNzIjoiaHR0cHM6Ly9hdXRoLmJydWNrZS5jbHViLyIsInN1YiI6ImF1dGgwfDVhMjA1NGZmNDUxNTc3MTFiZTgxODJmNCIsImF1ZCI6IkVxbjdHTUV3VzhDbmN1S2FhcFRuNWs5VEJ0MzRQdldmIiwiaWF0IjoxNTM2Nzg1NTMxLCJleHAiOjE1MzY4MjE1MzF9.mZGsJyJYyp_mkINcnV0JRJ6QPsTXUE8FrpRTruAIqhE' + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuaWNrbmFtZSI6ImpvaG5mb28iLCJuYW1lIjoiam9obmZvb0BnbWFpbC5jb20iLCJwaWN0dXJlIjoiaHR0cHM6Ly9zLmdyYXZhdGFyLmNvbS9hdmF0YXIvMzhmYTAwMjQyM2JkOGM5NDFjNmVkMDU4OGI2MGZmZWQ_cz00ODAmcj1wZyZkPWh0dHBzJTNBJTJGJTJGY2RuLmF1dGgwLmNvbSUyRmF2YXRhcnMlMkZqby5wbmciLCJ1cGRhdGVkX2F0IjoiMjAxOC0wOS0xMlQyMDo1MjoxMS4zMDZaIiwiZW1haWwiOiJqb2huZm9vQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiaXNzIjoiaHR0cHM6Ly9hdXRoLmJydWNrZS5jbHViLyIsInN1YiI6ImF1dGgwfDVhMjA1NGZmNDUxNTc3MTFiZTgxODJmNCIsImF1ZCI6IkVxbjdHTUV3VzhDbmN1S2FhcFRuNWs5VEJ0MzRQdldmIiwiaWF0IjoxNTM2Nzg1NTMxLCJleHAiOjE1MzY4MjE1MzF9.mZGsJyJYyp_mkINcnV0JRJ6QPsTXUE8FrpRTruAIqhE', }) ); - } + }, }; - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { + const oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { clientSecret: CLIENT_SECRET, - supportedAlgorithms: ['RS256'] + supportedAlgorithms: ['RS256'], }); - oauthWithValidation.create(PARAMS, DATA, function(e) { + oauthWithValidation.create(PARAMS, DATA, (e) => { expect(e.message).to.eq('invalid algorithm'); done(); }); }); - it('fails with a RS256 id_token and `options.supportedAlgorithms===HS256`', done => { - var oauth = { - create: function() { - return new Promise(res => - res({ - id_token: - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik5FVkJOVU5CT1RneFJrRTVOa1F6UXpjNE9UQkVNRUZGUkRRNU4wUTJRamswUmtRMU1qRkdNUSJ9.eyJuaWNrbmFtZSI6ImpvaG5mb28iLCJuYW1lIjoiam9obmZvb0BnbWFpbC5jb20iLCJwaWN0dXJlIjoiaHR0cHM6Ly9zLmdyYXZhdGFyLmNvbS9hdmF0YXIvMzhmYTAwMjQyM2JkOGM5NDFjNmVkMDU4OGI2MGZmZWQ_cz00ODAmcj1wZyZkPWh0dHBzJTNBJTJGJTJGY2RuLmF1dGgwLmNvbSUyRmF2YXRhcnMlMkZqby5wbmciLCJ1cGRhdGVkX2F0IjoiMjAxOC0wOS0xMlQyMDo1NTozMi4xMTlaIiwiZW1haWwiOiJqb2huZm9vQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiaXNzIjoiaHR0cHM6Ly9hdXRoLmJydWNrZS5jbHViLyIsInN1YiI6ImF1dGgwfDVhMjA1NGZmNDUxNTc3MTFiZTgxODJmNCIsImF1ZCI6IkVxbjdHTUV3VzhDbmN1S2FhcFRuNWs5VEJ0MzRQdldmIiwiaWF0IjoxNTM2Nzg1NzMyLCJleHAiOjE1MzY4MjE3MzJ9.i8iBJntBiSPRLIJdLmgTwnT_FXamc4ug8al8Ws1X-P7UAxbEaaa3irjqfBnDf50tDAQkHFcwIKiMDIrEHHBEPPEc7MH8dlxDAr80Pr8-T-M_ls8U6KccBGfrsurlJaU6qMVSfUP25kmZm5torI0D81c9rZRWcdpb64EnZCvqpUPWZjap__PoC-G88NRH_28jT_hV-bGYgbjJ3FqL_xTZ2u866bQljt1oJlOf3vvLIL4tW9MYdYxOvh7VZXWji9TirrjCb6cuq-CZ5ZWTSpV_NRC24BMdGx_Mu-4EBUMb8uWiaLBrjJgb_NtOZXY6p6PeJQuX5S2MeD2z_SCXOcwukQ' - }) - ); - } - }; - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { - clientSecret: CLIENT_SECRET, - domain: 'brucke.auth0.com', - supportedAlgorithms: ['HS256'] - }); - oauthWithValidation.create(PARAMS, DATA, function(e) { - expect(e.message).to.eq('invalid algorithm'); - done(); + + it('fails with a RS256 id_token and `options.supportedAlgorithms===HS256`', (done) => { + createCertificate((c) => { + const idtoken = jwt.sign({ foo: 'bar' }, c.serviceKey, { + algorithm: 'RS256', + issuer: 'https://auth.brucke.club', + audience: 'foobar', + expiresIn: '1d', + }); + const oauth = { + create() { + return new Promise((resolve) => + resolve({ + id_token: idtoken, + }) + ); + }, + }; + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + cb(null, { publicKey: c.publicKey }); + }, + })); + jwksClientStub.prototype = {}; + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + 'jwks-rsa': jwksClientStub, + } + ); + + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + clientSecret: CLIENT_SECRET, + domain: 'auth.brucke.club', + supportedAlgorithms: ['HS256'], + }); + oauthWithValidation.create(PARAMS, DATA, (e) => { + expect(e.message).to.eq('invalid algorithm'); + done(); + }); }); }); - it('fails when `token.exp` is expired', done => { - var oauth = { - create: function() { - return new Promise(res => - res({ - id_token: - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik5FVkJOVU5CT1RneFJrRTVOa1F6UXpjNE9UQkVNRUZGUkRRNU4wUTJRamswUmtRMU1qRkdNUSJ9.eyJuaWNrbmFtZSI6ImpvaG5mb28iLCJuYW1lIjoiam9obmZvb0BnbWFpbC5jb20iLCJwaWN0dXJlIjoiaHR0cHM6Ly9zLmdyYXZhdGFyLmNvbS9hdmF0YXIvMzhmYTAwMjQyM2JkOGM5NDFjNmVkMDU4OGI2MGZmZWQ_cz00ODAmcj1wZyZkPWh0dHBzJTNBJTJGJTJGY2RuLmF1dGgwLmNvbSUyRmF2YXRhcnMlMkZqby5wbmciLCJ1cGRhdGVkX2F0IjoiMjAxOC0wOS0xMlQyMToxNzoyNy41NjVaIiwiZW1haWwiOiJqb2huZm9vQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiaXNzIjoiaHR0cHM6Ly9icnVja2UuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDVhMjA1NGZmNDUxNTc3MTFiZTgxODJmNCIsImF1ZCI6IkVxbjdHTUV3VzhDbmN1S2FhcFRuNWs5VEJ0MzRQdldmIiwiaWF0IjoxNTM2Nzg3MDQ3LCJleHAiOjE1MzY3ODcwNTJ9.Wn6ie7sXQ7jG94MDumSa2vciKkt5qrDN8LGWw1U9cz8Oh15JxFZOxtPJxWST5t6i8biJ4l7fvjez7KkoibRf9TPXpe0VxE2SsQCy-H2TRlUSnodBg25WRPPKmXvA6tB_CeaZjDplaTV21fnvcRq7kCwl_O91meWS7Qs3rEWvrD_M63LvDPvAReKcNFRg42p_nZS5fnq2CLC6OHUBznkZfMforNJ8YC0GufcrBd2lRaNljF57Z6fHSupfwY9vLIxfp-nx7yYl7H1vjp75f-08h8mOLRgZdpCjG3z8QKCBwsY_5t8dnQfZiUsGhRFx6hsTb6BC35JHkNHSyOw75tfl9A' - }) - ); - } - }; - var oauthWithValidation = new OAUthWithIDTokenValidation(oauth, { - clientSecret: CLIENT_SECRET, - domain: 'auth.brucke.club', - supportedAlgorithms: ['RS256'] - }); - oauthWithValidation.create(PARAMS, DATA, function(e, d) { - expect(e.message).to.eq('jwt expired'); - done(); + + it('fails when `token.exp` is expired', (done) => { + createCertificate((c) => { + const idtoken = jwt.sign({ foo: 'bar' }, c.serviceKey, { + algorithm: 'RS256', + issuer: 'https://auth.brucke.club', + audience: 'foobar', + expiresIn: '-1h', + }); + const oauth = { + create() { + return new Promise((resolve) => + resolve({ + id_token: idtoken, + }) + ); + }, + }; + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + cb(null, { publicKey: c.publicKey }); + }, + })); + jwksClientStub.prototype = {}; + const OAUthWithIDTokenValidationProxy = proxyquire( + '../../src/auth/OAUthWithIDTokenValidation', + { + 'jwks-rsa': jwksClientStub, + } + ); + + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + clientSecret: CLIENT_SECRET, + domain: 'auth.brucke.club', + supportedAlgorithms: ['RS256'], + }); + oauthWithValidation.create(PARAMS, DATA, (e) => { + expect(e.message).to.eq('jwt expired'); + done(); + }); }); }); - describe('when using a valid certificate to generate an invalid id_token', function() { - it('fails when `token.aud` is invalid', done => { - createCertificate(function(c) { - var idtoken = jwt.sign({ foo: 'bar' }, c.serviceKey, { + + describe('when using a valid certificate to generate an invalid id_token', () => { + it('fails when `token.aud` is invalid', (done) => { + createCertificate((c) => { + const idtoken = jwt.sign({ foo: 'bar' }, c.serviceKey, { algorithm: 'RS256', audience: 'wrong_audience', - expiresIn: '1h' + expiresIn: '1h', }); - var oauth = { - create: function() { - return new Promise(res => - res({ - id_token: idtoken + const oauth = { + create() { + return new Promise((resolve) => + resolve({ + id_token: idtoken, }) ); - } + }, }; - var jwksClientStub = sinon.spy(function() { - return { - getSigningKey: function(kid, cb) { - cb(null, { publicKey: c.publicKey }); - } - }; - }); - OAUthWithIDTokenValidationProxy = proxyquire( + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + cb(null, { publicKey: c.publicKey }); + }, + })); + jwksClientStub.prototype = {}; + const OAUthWithIDTokenValidationProxy = proxyquire( '../../src/auth/OAUthWithIDTokenValidation', { - 'jwks-rsa': jwksClientStub + 'jwks-rsa': jwksClientStub, } ); - var oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { clientId: 'foobar', clientSecret: CLIENT_SECRET, domain: 'brucke.auth0.com', - supportedAlgorithms: ['RS256'] + supportedAlgorithms: ['RS256'], }); - oauthWithValidation.create(PARAMS, DATA, function(e) { + oauthWithValidation.create(PARAMS, DATA, (e) => { expect(e.message).to.eq('jwt audience invalid. expected: foobar'); done(); }); }); }); - it('fails when `token.iss` is invalid', done => { + + it('fails when `token.iss` is invalid', (done) => { const TEST_AUDIENCE = 'foobar'; - createCertificate(function(c) { - var idtoken = jwt.sign({ foo: 'bar' }, c.serviceKey, { + createCertificate((c) => { + const idtoken = jwt.sign({ foo: 'bar' }, c.serviceKey, { algorithm: 'RS256', issuer: 'wrong_issuer', audience: TEST_AUDIENCE, - expiresIn: '1h' + expiresIn: '1h', }); - var oauth = { - create: function() { - return new Promise(res => - res({ - id_token: idtoken + const oauth = { + create() { + return new Promise((resolve) => + resolve({ + id_token: idtoken, }) ); - } + }, }; - var jwksClientStub = sinon.spy(function() { - return { - getSigningKey: function(kid, cb) { - cb(null, { publicKey: c.publicKey }); - } - }; - }); - OAUthWithIDTokenValidationProxy = proxyquire( + const jwksClientStub = sinon.spy(() => ({ + getSigningKey(kid, cb) { + cb(null, { publicKey: c.publicKey }); + }, + })); + jwksClientStub.prototype = {}; + const OAUthWithIDTokenValidationProxy = proxyquire( '../../src/auth/OAUthWithIDTokenValidation', { - 'jwks-rsa': jwksClientStub + 'jwks-rsa': jwksClientStub, } ); - var oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { + + const oauthWithValidation = new OAUthWithIDTokenValidationProxy(oauth, { clientId: 'foobar', clientSecret: CLIENT_SECRET, domain: 'brucke.auth0.com', - supportedAlgorithms: ['RS256'] + supportedAlgorithms: ['RS256'], }); - oauthWithValidation.create(PARAMS, DATA, function(e) { + oauthWithValidation.create(PARAMS, DATA, (e) => { expect(e.message).to.eq('jwt issuer invalid. expected: https://brucke.auth0.com/'); done(); }); diff --git a/test/auth/oauth.tests.js b/test/auth/oauth.tests.js index f91d4104e..805239a49 100644 --- a/test/auth/oauth.tests.js +++ b/test/auth/oauth.tests.js @@ -1,108 +1,105 @@ -var expect = require('chai').expect; -var extend = require('util')._extend; -var nock = require('nock'); -var Promise = require('bluebird'); -var sinon = require('sinon'); - -// Constants. -var SRC_DIR = '../../src'; -var DOMAIN = 'tenant.auth0.com'; -var API_URL = 'https://' + DOMAIN; -var CLIENT_ID = 'TEST_CLIENT_ID'; -var CLIENT_SECRET = 'TEST_CLIENT_SECRET'; - -var ArgumentError = require('rest-facade').ArgumentError; -var Authenticator = require(SRC_DIR + '/auth/OAuthAuthenticator'); -var OAUthWithIDTokenValidation = require('../../src/auth/OAUthWithIDTokenValidation'); - -var validOptions = { +const { expect } = require('chai'); +const nock = require('nock'); +const sinon = require('sinon'); + +const DOMAIN = 'tenant.auth0.com'; +const API_URL = `https://${DOMAIN}`; +const CLIENT_ID = 'TEST_CLIENT_ID'; +const CLIENT_SECRET = 'TEST_CLIENT_SECRET'; + +const { ArgumentError } = require('rest-facade'); +const Authenticator = require(`../../src/auth/OAuthAuthenticator`); +const OAUthWithIDTokenValidation = require('../../src/auth/OAUthWithIDTokenValidation'); + +const validOptions = { baseUrl: API_URL, clientId: CLIENT_ID, - clientSecret: CLIENT_SECRET + clientSecret: CLIENT_SECRET, }; -describe('OAuthAuthenticator', function() { - beforeEach(function() { +describe('OAuthAuthenticator', () => { + beforeEach(() => { sinon.spy(OAUthWithIDTokenValidation.prototype, 'create'); }); - afterEach(function() { + afterEach(() => { OAUthWithIDTokenValidation.prototype.create.restore(); nock.cleanAll(); }); - describe('#constructor', function() { - it('should require an options object', function() { - expect(Authenticator).to.throw(ArgumentError, 'Missing authenticator options'); + describe('#constructor', () => { + it('should require an options object', () => { + expect(() => { + new Authenticator(); + }).to.throw(ArgumentError, 'Missing authenticator options'); - expect(Authenticator.bind(null, 1)).to.throw( - ArgumentError, - 'The authenticator options must be an object' - ); + expect(() => { + new Authenticator(1); + }).to.throw(ArgumentError, 'The authenticator options must be an object'); - expect(Authenticator.bind(null, validOptions)).to.not.throw(ArgumentError); + expect(() => { + new Authenticator(validOptions); + }).to.not.throw(ArgumentError); }); }); - describe('instance', function() { - var methods = [ + describe('instance', () => { + const methods = [ 'signIn', 'socialSignIn', 'passwordGrant', 'authorizationCodeGrant', - 'refreshToken' + 'refreshToken', ]; - var authenticator = new Authenticator(validOptions); + const authenticator = new Authenticator(validOptions); - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, () => { expect(authenticator[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#signIn', function() { - var path = '/oauth/ro'; - var userData = { + describe('#signIn', () => { + const path = '/oauth/ro'; + const userData = { username: 'username', password: 'pwd', - connection: 'Username-Password-Authentication' + connection: 'Username-Password-Authentication', + }; + const options = { + forwardedFor: '0.0.0.0', }; - beforeEach(function() { + beforeEach(function () { this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { + it('should require an object as first argument', function () { expect(this.authenticator.signIn).to.throw(ArgumentError, 'Missing user data object'); }); - it('should require a connection', function() { - var auth = this.authenticator; - var signIn = auth.signIn.bind(auth, {}); + it('should require a connection', function () { + const auth = this.authenticator; + const signIn = auth.signIn.bind(auth, {}); expect(signIn).to.throw(ArgumentError, 'connection field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.signIn(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { - this.authenticator - .signIn(userData) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise when no callback is provided', function (done) { + this.authenticator.signIn(userData).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; this.authenticator .signIn(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -110,12 +107,12 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should include the user data un the request', function(done) { + it('should include the user data un the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -127,7 +124,7 @@ describe('OAuthAuthenticator', function() { this.authenticator .signIn(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -135,18 +132,16 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); this.authenticator .signIn(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -154,18 +149,16 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should allow the user to specify the connection', function(done) { + it('should allow the user to specify the connection', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'Username-Password-Authentication'; - }) + const request = nock(API_URL) + .post(path, (body) => body.connection === 'Username-Password-Authentication') .reply(200); this.authenticator .signIn(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -173,18 +166,16 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should use password as default grant type', function(done) { + it('should use password as default grant type', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'password'; - }) + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'password') .reply(200); this.authenticator .signIn(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -192,19 +183,17 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should allow the user to specify the grant type', function(done) { + it('should allow the user to specify the grant type', function (done) { nock.cleanAll(); - var data = extend({ grant_type: 'TEST_GRANT' }, userData); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'TEST_GRANT'; - }) + const data = { grant_type: 'TEST_GRANT', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'TEST_GRANT') .reply(200); this.authenticator .signIn(data) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -212,28 +201,46 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should use the openid scope by default', function(done) { + it('should use the openid scope by default', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.scope === 'openid'; - }) + const request = nock(API_URL) + .post(path, (body) => body.scope === 'openid') .reply(200); this.authenticator .signIn(userData) - .then(function() { + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should make it possible to pass auth0-forwarded-for header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, function () { + return this.headers['auth0-forwarded-for'] === options.forwardedFor; + }) + .reply(200); + + this.authenticator + .signIn(userData, options) + .then(() => { expect(request.isDone()).to.be.true; done(); }) .catch(done); }); - it('should use OAUthWithIDTokenValidation', function(done) { + + it('should use OAUthWithIDTokenValidation', function (done) { this.authenticator .signIn(userData) - .then(function() { + .then(() => { expect(OAUthWithIDTokenValidation.prototype.create.calledOnce).to.be.true; done(); }) @@ -241,55 +248,56 @@ describe('OAuthAuthenticator', function() { }); }); - describe('#passwordGrant', function() { - var path = '/oauth/token'; - var userData = { + describe('#passwordGrant', () => { + const path = '/oauth/token'; + const userData = { username: 'username', - password: 'pwd' + password: 'pwd', + }; + const options = { + forwardedFor: '0.0.0.0', }; - beforeEach(function() { + beforeEach(function () { this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { + it('should require an object as first argument', function () { expect(this.authenticator.passwordGrant).to.throw(ArgumentError, 'Missing user data object'); }); - it('should require a username', function() { - var auth = this.authenticator; - var signIn = auth.passwordGrant.bind(auth, { password: 'pwd' }); + it('should require a username', function () { + const auth = this.authenticator; + const signIn = auth.passwordGrant.bind(auth, { password: 'pwd' }); expect(signIn).to.throw(ArgumentError, 'username field is required'); }); - it('should require a password', function() { - var auth = this.authenticator; - var signIn = auth.passwordGrant.bind(auth, { username: 'samples@auth0.com' }); + it('should require a password', function () { + const auth = this.authenticator; + const signIn = auth.passwordGrant.bind(auth, { username: 'samples@auth0.com' }); expect(signIn).to.throw(ArgumentError, 'password field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.passwordGrant(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { + it('should return a promise when no callback is provided', function (done) { this.authenticator .passwordGrant(userData) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; this.authenticator .passwordGrant(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -297,12 +305,12 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should include the user data in the request', function(done) { + it('should include the user data in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -314,7 +322,7 @@ describe('OAuthAuthenticator', function() { this.authenticator .passwordGrant(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -322,18 +330,16 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); this.authenticator .passwordGrant(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -341,18 +347,16 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should include the Auth0 client secret in the request', function(done) { + it('should include the Auth0 client secret in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_secret === CLIENT_SECRET; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_secret === CLIENT_SECRET) .reply(200); this.authenticator .passwordGrant(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -360,21 +364,21 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should allow the user to specify the realm', function(done) { + it('should allow the user to specify the realm', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return ( + const request = nock(API_URL) + .post( + path, + (body) => body.realm === 'Username-Password-Authentication' && body.grant_type === 'http://auth0.com/oauth/grant-type/password-realm' - ); - }) + ) .reply(200); this.authenticator .passwordGrant(Object.assign({ realm: 'Username-Password-Authentication' }, userData)) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -382,28 +386,46 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should use password as default grant type', function(done) { + it('should use password as default grant type', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'password'; - }) + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'password') .reply(200); this.authenticator .passwordGrant(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); }) .catch(done); }); - it('should use OAUthWithIDTokenValidation', function(done) { + + it('should make it possible to pass auth0-forwarded-for header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, function () { + return this.headers['auth0-forwarded-for'] === options.forwardedFor; + }) + .reply(200); + + this.authenticator + .passwordGrant(userData, options) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should use OAUthWithIDTokenValidation', function (done) { this.authenticator .passwordGrant(userData) - .then(function() { + .then(() => { expect(OAUthWithIDTokenValidation.prototype.create.calledOnce).to.be.true; done(); }) @@ -411,49 +433,48 @@ describe('OAuthAuthenticator', function() { }); }); - describe('#refreshToken', function() { - var path = '/oauth/token'; - var userData = { - refresh_token: 'refresh_token' + describe('#refreshToken', () => { + const path = '/oauth/token'; + const userData = { + refresh_token: 'refresh_token', }; - beforeEach(function() { + + beforeEach(function () { this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { - expect(this.authenticator.refreshToken).to.throw(ArgumentError, 'Missing user data object'); + it('should require an object as first argument', function () { + expect(this.authenticator.refreshToken).to.throw(ArgumentError, 'Missing data object'); }); - it('should require a refreshToken', function() { - var auth = this.authenticator; - var refresh = auth.refreshToken.bind(auth, {}); + it('should require a refreshToken', function () { + const auth = this.authenticator; + const refresh = auth.refreshToken.bind(auth, {}); expect(refresh).to.throw(ArgumentError, 'refresh_token is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.refreshToken(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { + it('should return a promise when no callback is provided', function (done) { this.authenticator .refreshToken(userData) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; this.authenticator .refreshToken(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); }) .catch(done); }); - it('should include the user data in the request', function(done) { + it('should include the user data in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -463,37 +484,46 @@ describe('OAuthAuthenticator', function() { .reply(200); this.authenticator .refreshToken(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); }) .catch(done); }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); this.authenticator .refreshToken(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); }) .catch(done); }); - it('should use refresh_token as default grant type', function(done) { + it('should include the Auth0 client secret in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'refresh_token'; + const request = nock(API_URL) + .post(path, (body) => body.client_secret === CLIENT_SECRET) + .reply(200); + this.authenticator + .refreshToken(userData) + .then(() => { + expect(request.isDone()).to.be.true; + done(); }) + .catch(done); + }); + it('should use refresh_token as default grant type', function (done) { + nock.cleanAll(); + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'refresh_token') .reply(200); this.authenticator .refreshToken(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); }) @@ -501,162 +531,123 @@ describe('OAuthAuthenticator', function() { }); }); - describe('#socialSignIn', function() { - var path = '/oauth/access_token'; - var userData = { + describe('#socialSignIn', () => { + const path = '/oauth/access_token'; + const userData = { access_token: 'TEST_ACCESS_TOKEN', - connection: 'facebook' + connection: 'facebook', }; - beforeEach(function() { + beforeEach(function () { this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { - var auth = this.authenticator; - var socialSignIn = auth.socialSignIn.bind(auth); - var message = 'Missing user credential objects'; + it('should require an object as first argument', function () { + const auth = this.authenticator; + const socialSignIn = auth.socialSignIn.bind(auth); + const message = 'Missing user credential objects'; expect(socialSignIn).to.throw(ArgumentError, message); expect(socialSignIn.bind(auth, userData)).to.not.throw(ArgumentError, message); }); - it('should require an access token', function() { - var auth = this.authenticator; - var socialSignIn = auth.socialSignIn.bind(auth, {}); - var message = 'access_token field is required'; + it('should require an access token', function () { + const auth = this.authenticator; + const socialSignIn = auth.socialSignIn.bind(auth, {}); + const message = 'access_token field is required'; expect(socialSignIn).to.throw(ArgumentError, message); }); - it('should require a connection', function() { - var auth = this.authenticator; - var data = { - access_token: userData.access_token + it('should require a connection', function () { + const auth = this.authenticator; + const data = { + access_token: userData.access_token, }; - var socialSignIn = auth.socialSignIn.bind(auth, data); - var message = 'connection field is required'; + const socialSignIn = auth.socialSignIn.bind(auth, data); + const message = 'connection field is required'; expect(socialSignIn).to.throw(ArgumentError, message); }); - it('should require a connection', function() { - var auth = this.authenticator; - var data = { - access_token: userData.access_token + it('should require a connection', function () { + const auth = this.authenticator; + const data = { + access_token: userData.access_token, }; - var socialSignIn = auth.socialSignIn.bind(auth, data); - var message = 'connection field is required'; + const socialSignIn = auth.socialSignIn.bind(auth, data); + const message = 'connection field is required'; expect(socialSignIn).to.throw(ArgumentError, message); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.socialSignIn(userData, done.bind(null, null)); }); - it('should return a promise when no callback is given', function() { - var returnValue = this.authenticator.socialSignIn(userData); - - expect(returnValue).to.be.an.instanceOf(Promise); + it('should return a promise when no callback is given', function (done) { + this.authenticator + .socialSignIn(userData) + .then(() => done()) + .catch(() => done()); }); - it('should not return a promise when a callback is given', function() { - var cb = function() {}; - var returnValue = this.authenticator.socialSignIn(userData, cb); + it('should not return a promise when a callback is given', function () { + const cb = function () {}; + const returnValue = this.authenticator.socialSignIn(userData, cb); expect(returnValue).to.be.undefined; }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; - this.authenticator.socialSignIn(userData).then(function() { + this.authenticator.socialSignIn(userData).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should use the default client ID if none specified', function(done) { + it('should allow the user to specify a custom client ID', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path) - .query({ client_id: CLIENT_ID }) - .reply(200); - - this.authenticator.socialSignIn(userData).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); - }); - - it('should allow the user to specify a custom client ID', function(done) { - nock.cleanAll(); - - var data = extend({}, userData); - var request = nock(API_URL) - .post(path) - .query({ client_id: 'OVERRIDEN_ID' }) - .reply(200); - + const data = { ...userData }; data.client_id = 'OVERRIDEN_ID'; + const request = nock(API_URL).post(path, data).reply(200); - this.authenticator.socialSignIn(data).then(function() { + this.authenticator.socialSignIn(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should use the openid scope by default', function(done) { + it('should allow the user to specify the scope', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path) - .query({ scope: 'openid' }) - .reply(200); - - this.authenticator.socialSignIn(userData).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); - }); - - it('should allow the user to specify the scope', function(done) { - nock.cleanAll(); - - var data = extend({}, userData); - var request = nock(API_URL) - .post(path) - .query({ scope: 'openid name email' }) - .reply(200); - + const data = { ...userData }; data.scope = 'openid name email'; + const request = nock(API_URL).post(path, data).reply(200); - this.authenticator.socialSignIn(data).then(function() { + this.authenticator.socialSignIn(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should use application/json as Content-Type', function(done) { + it('should use application/json as Content-Type', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post(path) .matchHeader('Content-Type', 'application/json') .reply(200); - this.authenticator.socialSignIn(userData).then(function() { + this.authenticator.socialSignIn(userData).then(() => { expect(request.isDone()).to.be.true; done(); @@ -664,65 +655,63 @@ describe('OAuthAuthenticator', function() { }); }); - describe('#clientCredentials', function() { - var path = '/oauth/token'; - var options = { + describe('#clientCredentials', () => { + const path = '/oauth/token'; + const options = { audience: 'audience', - scope: 'scope' + scope: 'scope', }; - beforeEach(function() { + beforeEach(function () { this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { + it('should require an object as first argument', function () { expect(this.authenticator.clientCredentialsGrant).to.throw( ArgumentError, 'Missing options object' ); }); - it('should require the client_id', function() { - var authenticator = new Authenticator({}); - expect(function() { + it('should require the client_id', () => { + const authenticator = new Authenticator({}); + expect(() => { authenticator.clientCredentialsGrant({}); }).to.throw(ArgumentError, 'client_id field is required'); }); - it('should require the client_secret', function() { - var authenticator = new Authenticator({ - clientId: CLIENT_ID + it('should require the client_secret', () => { + const authenticator = new Authenticator({ + clientId: CLIENT_ID, }); - expect(function() { + expect(() => { authenticator.clientCredentialsGrant({}); }).to.throw(ArgumentError, 'client_secret field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.clientCredentialsGrant(options, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function() { + it('should return a promise when no callback is provided', function () { return this.authenticator.clientCredentialsGrant(options); }); - it('should perform a POST request to ' + path, function() { - var request = this.request; + it(`should perform a POST request to ${path}`, function () { + const { request } = this; - return this.authenticator.clientCredentialsGrant(options).then(function() { + return this.authenticator.clientCredentialsGrant(options).then(() => { expect(request.isDone()).to.be.true; }); }); - it('should include the options in the request', function() { + it('should include the options in the request', function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in options) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in options) { if (options[property] !== body[property]) { return false; } @@ -732,121 +721,122 @@ describe('OAuthAuthenticator', function() { }) .reply(200); - return this.authenticator.clientCredentialsGrant(options).then(function() { + return this.authenticator.clientCredentialsGrant(options).then(() => { expect(request.isDone()).to.be.true; }); }); - it('should include the Auth0 client ID and secret in the request', function() { + it('should include the Auth0 client ID and secret in the request', function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID && body.client_secret === CLIENT_SECRET; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID && body.client_secret === CLIENT_SECRET) .reply(200); - return this.authenticator.clientCredentialsGrant(options).then(function() { + return this.authenticator.clientCredentialsGrant(options).then(() => { expect(request.isDone()).to.be.true; }); }); - it('should allow the user to specify the audience and scope', function() { + it('should allow the user to specify the audience and scope', function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.audience === 'audience' && body.scope === 'scope'; - }) + const request = nock(API_URL) + .post(path, (body) => body.audience === 'audience' && body.scope === 'scope') .reply(200); - return this.authenticator.clientCredentialsGrant(options).then(function() { + return this.authenticator.clientCredentialsGrant(options).then(() => { expect(request.isDone()).to.be.true; }); }); - it('should use client_credentials as default grant type', function() { + it('should use client_credentials as default grant type', function () { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'client_credentials'; - }) + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'client_credentials') .reply(200); - return this.authenticator.clientCredentialsGrant(options).then(function() { + return this.authenticator.clientCredentialsGrant(options).then(() => { expect(request.isDone()).to.be.true; }); }); - it('should allow the user to specify the grant type', function() { + it('should allow the user to specify the grant type', function () { nock.cleanAll(); - var data = extend({ grant_type: 'TEST_GRANT' }, options); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'TEST_GRANT'; - }) + const data = { grant_type: 'TEST_GRANT', ...options }; + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'TEST_GRANT') .reply(200); - return this.authenticator.clientCredentialsGrant(data).then(function() { + return this.authenticator.clientCredentialsGrant(data).then(() => { expect(request.isDone()).to.be.true; }); }); + + it('should sanitize sensitive request data from errors', function () { + nock.cleanAll(); + + nock(API_URL).post(path).reply(401); + + return this.authenticator.clientCredentialsGrant(options).catch((err) => { + const originalRequestData = err.originalError.response.request._data; + expect(originalRequestData.client_secret).to.not.equal(CLIENT_SECRET); + }); + }); }); - describe('#authorizationCodeGrant', function() { - var path = '/oauth/token'; - var data = { + describe('#authorizationCodeGrant', () => { + const path = '/oauth/token'; + const data = { code: 'auth_code', - redirect_uri: API_URL + redirect_uri: API_URL, }; - beforeEach(function() { + beforeEach(function () { this.authenticator = new Authenticator(validOptions); - this.request = nock(API_URL) - .post(path) - .reply(200); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { + it('should require an object as first argument', function () { expect(this.authenticator.authorizationCodeGrant).to.throw( ArgumentError, 'Missing options object' ); }); - it('should require a code', function() { - var auth = this.authenticator; - var signIn = auth.authorizationCodeGrant.bind(auth, { redirect: API_URL }); + it('should require a code', function () { + const auth = this.authenticator; + const signIn = auth.authorizationCodeGrant.bind(auth, { redirect: API_URL }); expect(signIn).to.throw(ArgumentError, 'code field is required'); }); - it('should require a redirect_uri', function() { - var auth = this.authenticator; - var signIn = auth.authorizationCodeGrant.bind(auth, { code: 'auth_code' }); + it('should require a redirect_uri', function () { + const auth = this.authenticator; + const signIn = auth.authorizationCodeGrant.bind(auth, { code: 'auth_code' }); expect(signIn).to.throw(ArgumentError, 'redirect_uri field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.authorizationCodeGrant(data, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { + it('should return a promise when no callback is provided', function (done) { this.authenticator .authorizationCodeGrant(data) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; this.authenticator .authorizationCodeGrant(data) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -854,12 +844,12 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should include the data in the request', function(done) { + it('should include the data in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in data) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in data) { if (data[property] !== body[property]) { return false; } @@ -871,7 +861,7 @@ describe('OAuthAuthenticator', function() { this.authenticator .authorizationCodeGrant(data) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -879,18 +869,16 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); this.authenticator .authorizationCodeGrant(data) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -898,18 +886,16 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should include the Auth0 client secret in the request', function(done) { + it('should include the Auth0 client secret in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_secret === CLIENT_SECRET; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_secret === CLIENT_SECRET) .reply(200); this.authenticator .authorizationCodeGrant(data) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -917,28 +903,27 @@ describe('OAuthAuthenticator', function() { .catch(done); }); - it('should use authorization_code as default grant type', function(done) { + it('should use authorization_code as default grant type', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'authorization_code'; - }) + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'authorization_code') .reply(200); this.authenticator .authorizationCodeGrant(data) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); }) .catch(done); }); - it('should use OAUthWithIDTokenValidation', function(done) { + + it('should use OAUthWithIDTokenValidation', function (done) { this.authenticator .authorizationCodeGrant(data) - .then(function() { + .then(() => { expect(OAUthWithIDTokenValidation.prototype.create.calledOnce).to.be.true; done(); }) diff --git a/test/auth/passwordless.tests.js b/test/auth/passwordless.tests.js index 67271376d..6175ee2c8 100644 --- a/test/auth/passwordless.tests.js +++ b/test/auth/passwordless.tests.js @@ -1,304 +1,551 @@ -var expect = require('chai').expect; -var extend = require('util')._extend; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -// Constants. -var SRC_DIR = '../../src'; -var DOMAIN = 'tenant.auth0.com'; -var API_URL = 'https://' + DOMAIN; -var CLIENT_ID = 'TEST_CLIENT_ID'; +const DOMAIN = 'tenant.auth0.com'; +const API_URL = `https://${DOMAIN}`; +const CLIENT_ID = 'TEST_CLIENT_ID'; -var ArgumentError = require('rest-facade').ArgumentError; -var Authenticator = require(SRC_DIR + '/auth/PasswordlessAuthenticator'); -var OAuth = require(SRC_DIR + '/auth/OAuthAuthenticator'); +const { ArgumentError } = require('rest-facade'); +const Authenticator = require(`../../src/auth/PasswordlessAuthenticator`); +const OAuth = require(`../../src/auth/OAuthAuthenticator`); -var validOptions = { +const validOptions = { baseUrl: API_URL, - clientId: CLIENT_ID + clientId: CLIENT_ID, }; -describe('PasswordlessAuthenticator', function() { - afterEach(function() { +describe('PasswordlessAuthenticator', () => { + afterEach(() => { nock.cleanAll(); }); - describe('#constructor', function() { - it('should require an options object', function() { - expect(Authenticator).to.throw(ArgumentError, 'Missing authenticator options'); + describe('#constructor', () => { + it('should require an options object', () => { + expect(() => { + new Authenticator(); + }).to.throw(ArgumentError, 'Missing authenticator options'); - expect(Authenticator.bind(null, 1)).to.throw( - ArgumentError, - 'The authenticator options must be an object' - ); + expect(() => { + new Authenticator(1); + }).to.throw(ArgumentError, 'The authenticator options must be an object'); - expect(Authenticator.bind(null, validOptions)).to.not.throw(ArgumentError); + expect(() => { + new Authenticator(validOptions); + }).to.not.throw(ArgumentError); }); }); - describe('instance', function() { - var methods = ['signIn', 'sendEmail', 'sendSMS']; - var oauth = new OAuth(validOptions); - var authenticator = new Authenticator(validOptions, oauth); + describe('instance', () => { + const methods = ['signIn', 'sendEmail', 'sendSMS']; + const oauth = new OAuth(validOptions); + const authenticator = new Authenticator(validOptions, oauth); - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, () => { expect(authenticator[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#signIn', function() { - var path = '/oauth/ro'; - var userData = { - username: 'username', - password: 'pwd' - }; + describe('#signIn', () => { + describe('/oauth/ro', () => { + const path = '/oauth/ro'; + const userData = { + username: 'username', + password: 'pwd', + }; + const options = { + forwardedFor: '0.0.0.0', + }; + + beforeEach(function () { + const oauth = new OAuth(validOptions); + this.authenticator = new Authenticator(validOptions, oauth); + this.request = nock(API_URL).post(path).reply(200); + }); - beforeEach(function() { - var oauth = new OAuth(validOptions); - this.authenticator = new Authenticator(validOptions, oauth); - this.request = nock(API_URL) - .post(path) - .reply(200); - }); + it('should require an object as first argument', function () { + expect(this.authenticator.signIn).to.throw(ArgumentError, 'Missing user data object'); + }); - it('should require an object as first argument', function() { - expect(this.authenticator.signIn).to.throw(ArgumentError, 'Missing user data object'); - }); + it('should require a phone number', function () { + const auth = this.authenticator; + const userData = { password: 'password' }; + const signIn = auth.signIn.bind(auth, userData); - it('should require a phone number', function() { - var auth = this.authenticator; - var userData = { password: 'password' }; - var signIn = auth.signIn.bind(auth, userData); + expect(signIn).to.throw(ArgumentError, 'username field (phone number) is required'); + }); - expect(signIn).to.throw(ArgumentError, 'username field (phone number) is required'); - }); + it('should require a verification code', function () { + const auth = this.authenticator; + const userData = { username: 'username' }; + const signIn = auth.signIn.bind(auth, userData); - it('should require a verification code', function() { - var auth = this.authenticator; - var userData = { username: 'username' }; - var signIn = auth.signIn.bind(auth, userData); + expect(signIn).to.throw(ArgumentError, 'password field (verification code) is required'); + }); - expect(signIn).to.throw(ArgumentError, 'password field (verification code) is required'); - }); + it('should accept a callback', function (done) { + this.authenticator.signIn(userData, done.bind(null, null)); + }); - it('should accept a callback', function(done) { - this.authenticator.signIn(userData, done.bind(null, null)); - }); + it('should return a promise when no callback is provided', function (done) { + this.authenticator + .signIn(userData) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); - it('should return a promise when no callback is provided', function(done) { - this.authenticator - .signIn(userData) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); - }); + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; + done(); + }) + .catch(done); + }); - done(); - }) - .catch(done); + it('should include the user data in the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { + if (userData[property] !== body[property]) { + return false; + } + } + + return true; + }) + .reply(200); + + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should include the Auth0 client ID in the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) + .reply(200); + + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should use SMS connection', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, (body) => body.connection === 'sms') + .reply(200); + + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should use email connection', function (done) { + nock.cleanAll(); + const data = { connection: 'email', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.connection === 'email') + .reply(200); + + this.authenticator + .signIn(data) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should allow the user to specify the connection as sms or email', function (done) { + nock.cleanAll(); + + const data = { connection: 'TEST_CONNECTION', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.connection === 'sms' || body.connection === 'email') + .reply(200); + + this.authenticator + .signIn(data) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should use password as grant type', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, (body) => body.grant_type === 'password') + .reply(200); + + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should use the openid scope', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, (body) => body.scope === 'openid') + .reply(200); + + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should make it possible to pass auth0-forwarded-for header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, function () { + return this.headers['auth0-forwarded-for'] === options.forwardedFor; + }) + .reply(200); + + this.authenticator + .signIn(userData, options) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); }); - it('should include the user data in the request', function(done) { - nock.cleanAll(); + describe('/oauth/token', () => { + const path = '/oauth/token'; + const userData = { + username: 'username', + otp: '000000', + }; + const options = { + forwardedFor: '0.0.0.0', + }; + + beforeEach(function () { + const oauth = new OAuth(validOptions); + this.authenticator = new Authenticator(validOptions, oauth); + this.request = nock(API_URL).post(path).reply(200); + }); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { - if (userData[property] !== body[property]) { - return false; + it('should require an object as first argument', function () { + expect(this.authenticator.signIn).to.throw(ArgumentError, 'Missing user data object'); + }); + + it('should require a phone number', function () { + const auth = this.authenticator; + const userData = { otp: '000000' }; + const signIn = auth.signIn.bind(auth, userData); + + expect(signIn).to.throw(ArgumentError, 'username field (phone number) is required'); + }); + + it('should require a verification code', function () { + const auth = this.authenticator; + const userData = { username: 'username' }; + const signIn = auth.signIn.bind(auth, userData); + + expect(signIn).to.throw(ArgumentError, 'password field (verification code) is required'); + }); + + it('should accept a callback', function (done) { + this.authenticator.signIn(userData, done.bind(null, null)); + }); + + it('should return a promise when no callback is provided', function (done) { + this.authenticator + .signIn(userData) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; + + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should include the user data in the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { + if (userData[property] !== body[property]) { + return false; + } } - } - return true; - }) - .reply(200); + return true; + }) + .reply(200); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; - done(); - }) - .catch(done); - }); + done(); + }) + .catch(done); + }); - it('should include the Auth0 client ID in the request', function(done) { - nock.cleanAll(); + it('should include the Auth0 client ID in the request', function (done) { + nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) - .reply(200); + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) + .reply(200); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; - done(); - }) - .catch(done); - }); + done(); + }) + .catch(done); + }); - it('should use SMS connection', function(done) { - nock.cleanAll(); + it('should use SMS realm', function (done) { + nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'sms'; - }) - .reply(200); + const request = nock(API_URL) + .post(path, (body) => body.realm === 'sms') + .reply(200); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; - done(); - }) - .catch(done); - }); + done(); + }) + .catch(done); + }); - it('should use email connection', function(done) { - nock.cleanAll(); - var data = extend({ connection: 'email' }, userData); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'email'; - }) - .reply(200); + it('should use email realm', function (done) { + nock.cleanAll(); + const data = { realm: 'email', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.realm === 'email') + .reply(200); + + this.authenticator + .signIn(data) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); - this.authenticator - .signIn(data) - .then(function() { - expect(request.isDone()).to.be.true; + it('should allow the user to specify the realm as sms or email', function (done) { + nock.cleanAll(); - done(); - }) - .catch(done); - }); + const data = { realm: 'TEST_CONNECTION', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.realm === 'sms' || body.realm === 'email') + .reply(200); - it('should allow the user to specify the connection as sms or email', function(done) { - nock.cleanAll(); + this.authenticator + .signIn(data) + .then(() => { + expect(request.isDone()).to.be.true; - var data = extend({ connection: 'TEST_CONNECTION' }, userData); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'sms' || body.connection === 'email'; - }) - .reply(200); + done(); + }) + .catch(done); + }); - this.authenticator - .signIn(data) - .then(function() { - expect(request.isDone()).to.be.true; + it('should use otp as grant type', function (done) { + nock.cleanAll(); - done(); - }) - .catch(done); - }); + const request = nock(API_URL) + .post( + path, + (body) => body.grant_type === 'http://auth0.com/oauth/grant-type/passwordless/otp' + ) + .reply(200); - it('should use password as grant type', function(done) { - nock.cleanAll(); + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; - var request = nock(API_URL) - .post(path, function(body) { - return body.grant_type === 'password'; - }) - .reply(200); + done(); + }) + .catch(done); + }); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; + it('should use the openid scope', function (done) { + nock.cleanAll(); - done(); - }) - .catch(done); - }); + const request = nock(API_URL) + .post(path, (body) => body.scope === 'openid') + .reply(200); - it('should use the openid scope', function(done) { - nock.cleanAll(); + this.authenticator + .signIn(userData) + .then(() => { + expect(request.isDone()).to.be.true; - var request = nock(API_URL) - .post(path, function(body) { - return body.scope === 'openid'; - }) - .reply(200); + done(); + }) + .catch(done); + }); - this.authenticator - .signIn(userData) - .then(function() { - expect(request.isDone()).to.be.true; + it('should make it possible to pass auth0-forwarded-for header', function (done) { + nock.cleanAll(); - done(); - }) - .catch(done); + const request = nock(API_URL) + .post(path, function () { + return this.headers['auth0-forwarded-for'] === options.forwardedFor; + }) + .reply(200); + + this.authenticator + .signIn(userData, options) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should make it possible to use audience property', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, (body) => body.audience === 'TEST_AUDIENCE') + .reply(200); + + this.authenticator + .signIn( + { + ...userData, + audience: 'TEST_AUDIENCE', + }, + options + ) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); }); }); - describe('#sendEmail', function() { - var path = '/passwordless/start'; - var userData = { + describe('#sendEmail', () => { + const path = '/passwordless/start'; + const userData = { email: 'email@domain.com', - send: 'link' + send: 'link', + }; + const options = { + forwardedFor: '0.0.0.0', }; - beforeEach(function() { - var oauth = new OAuth(validOptions); + beforeEach(function () { + const oauth = new OAuth(validOptions); this.authenticator = new Authenticator(validOptions, oauth); - this.request = nock(API_URL) - .post(path) - .reply(200); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { - expect(this.authenticator.sendEmail).to.throw(ArgumentError, 'Missing user data object'); + it('should require an object as first argument', function () { + expect(() => { + this.authenticator.sendEmail(); + }).to.throw(ArgumentError, 'Missing user data object'); }); - it('should require an email', function() { - var auth = this.authenticator; - var userData = {}; - var sendEmail = auth.sendEmail.bind(auth, userData); + it('should require an email', function () { + const auth = this.authenticator; + const userData = {}; + const sendEmail = auth.sendEmail.bind(auth, userData); expect(sendEmail).to.throw(ArgumentError, 'email field is required'); }); - it('should require the send field', function() { - var auth = this.authenticator; - var userData = { email: 'email@domain.com' }; - var sendEmail = auth.sendEmail.bind(auth, userData); + it('should require the send field', function () { + const auth = this.authenticator; + const userData = { email: 'email@domain.com' }; + const sendEmail = auth.sendEmail.bind(auth, userData); expect(sendEmail).to.throw(ArgumentError, 'send field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.sendEmail(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { + it('should return a promise when no callback is provided', function (done) { this.authenticator .sendEmail(userData) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; this.authenticator .sendEmail(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -306,12 +553,12 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it('should include the user data in the request', function(done) { + it('should include the user data in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -323,7 +570,7 @@ describe('PasswordlessAuthenticator', function() { this.authenticator .sendEmail(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -331,18 +578,16 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); this.authenticator .sendEmail(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -350,18 +595,16 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it('should use the email connection', function(done) { + it('should use the email connection', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'email'; - }) + const request = nock(API_URL) + .post(path, (body) => body.connection === 'email') .reply(200); this.authenticator .sendEmail(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -369,21 +612,19 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it('should use the specified send type', function(done) { + it('should use the specified send type', function (done) { nock.cleanAll(); - var data = extend({}, userData); - var request = nock(API_URL) - .post(path, function(body) { - return body.send === 'code'; - }) + const data = { ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.send === 'code') .reply(200); data.send = 'code'; this.authenticator .sendEmail(data) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -391,19 +632,36 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it("shouldn't allow the user to specify the connection", function(done) { + it("shouldn't allow the user to specify the connection", function (done) { nock.cleanAll(); - var data = extend({ connection: 'TEST_CONNECTION' }, userData); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'email'; - }) + const data = { connection: 'TEST_CONNECTION', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.connection === 'email') .reply(200); this.authenticator .sendEmail(data) - .then(function() { + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should make it possible to pass auth0-forwarded-for header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, function () { + return this.headers['auth0-forwarded-for'] === options.forwardedFor; + }) + .reply(200); + + this.authenticator + .sendEmail(userData, options) + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -412,49 +670,50 @@ describe('PasswordlessAuthenticator', function() { }); }); - describe('#sendSMS', function() { - var path = '/passwordless/start'; - var userData = { - phone_number: '12345678' + describe('#sendSMS', () => { + const path = '/passwordless/start'; + const userData = { + phone_number: '12345678', + }; + const options = { + forwardedFor: '0.0.0.0', }; - beforeEach(function() { - var oauth = new OAuth(validOptions); + beforeEach(function () { + const oauth = new OAuth(validOptions); this.authenticator = new Authenticator(validOptions, oauth); - this.request = nock(API_URL) - .post(path) - .reply(200); + this.request = nock(API_URL).post(path).reply(200); }); - it('should require an object as first argument', function() { - expect(this.authenticator.sendSMS).to.throw(ArgumentError, 'Missing user data object'); + it('should require an object as first argument', function () { + expect(() => { + this.authenticator.sendSMS(); + }).to.throw(ArgumentError, 'Missing user data object'); }); - it('should require a phone number', function() { - var auth = this.authenticator; - var userData = {}; - var sendSMS = auth.sendSMS.bind(auth, userData); + it('should require a phone number', function () { + const auth = this.authenticator; + const userData = {}; - expect(sendSMS).to.throw(ArgumentError, 'phone_number field is required'); + expect(() => { + auth.sendSMS(userData); + }).to.throw(ArgumentError, 'phone_number field is required'); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.authenticator.sendSMS(userData, done.bind(null, null)); }); - it('should return a promise when no callback is provided', function(done) { - this.authenticator - .sendSMS(userData) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise when no callback is provided', function (done) { + this.authenticator.sendSMS(userData).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; this.authenticator .sendSMS(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -462,12 +721,12 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it('should include the user data in the request', function(done) { + it('should include the user data in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - for (var property in userData) { + const request = nock(API_URL) + .post(path, (body) => { + for (const property in userData) { if (userData[property] !== body[property]) { return false; } @@ -479,7 +738,7 @@ describe('PasswordlessAuthenticator', function() { this.authenticator .sendSMS(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -487,18 +746,16 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it('should include the Auth0 client ID in the request', function(done) { + it('should include the Auth0 client ID in the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(API_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); this.authenticator .sendSMS(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -506,18 +763,16 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it('should use the sms connection', function(done) { + it('should use the sms connection', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'sms'; - }) + const request = nock(API_URL) + .post(path, (body) => body.connection === 'sms') .reply(200); this.authenticator .sendSMS(userData) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -525,19 +780,36 @@ describe('PasswordlessAuthenticator', function() { .catch(done); }); - it("shouldn't allow the user to specify the connection", function(done) { + it("shouldn't allow the user to specify the connection", function (done) { nock.cleanAll(); - var data = extend({ connection: 'TEST_CONNECTION' }, userData); - var request = nock(API_URL) - .post(path, function(body) { - return body.connection === 'sms'; - }) + const data = { connection: 'TEST_CONNECTION', ...userData }; + const request = nock(API_URL) + .post(path, (body) => body.connection === 'sms') .reply(200); this.authenticator .sendSMS(data) - .then(function() { + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch(done); + }); + + it('should make it possible to pass auth0-forwarded-for header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(path, function () { + return this.headers['auth0-forwarded-for'] === options.forwardedFor; + }) + .reply(200); + + this.authenticator + .sendSMS(userData, options) + .then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/auth/tokens-manager.tests.js b/test/auth/tokens-manager.tests.js index 43241e9cd..3d3db40ec 100644 --- a/test/auth/tokens-manager.tests.js +++ b/test/auth/tokens-manager.tests.js @@ -1,128 +1,127 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var BASE_URL = 'https://tenant.auth0.com'; +const isPromise = (thing) => thing && typeof thing.then === 'function'; -var Promise = require('bluebird'); -var ArgumentError = require('rest-facade').ArgumentError; -var TokensManager = require('../../src/auth/TokensManager'); +const BASE_URL = 'https://tenant.auth0.com'; -describe('TokensManager', function() { - var validOptions = { +const { ArgumentError } = require('rest-facade'); +const TokensManager = require('../../src/auth/TokensManager'); + +describe('TokensManager', () => { + const validOptions = { baseUrl: BASE_URL, headers: { 'Content-Type': 'application/json', - 'Test-Header': 'TEST' + 'Test-Header': 'TEST', }, - clientId: 'CLIENT_ID' + clientId: 'CLIENT_ID', + clientSecret: 'CLIENT_SECRET', }; - afterEach(function() { + afterEach(() => { nock.cleanAll(); }); - describe('#constructor', function() { - it('should require an options object', function() { - expect(TokensManager).to.throw(ArgumentError, 'Missing tokens manager options'); + describe('#constructor', () => { + it('should require an options object', () => { + expect(() => { + new TokensManager(); + }).to.throw(ArgumentError, 'Missing tokens manager options'); }); - it('should require a base URL', function() { - var manager = TokensManager.bind(null, {}); - - expect(manager).to.throw(ArgumentError, 'baseUrl field is required'); + it('should require a base URL', () => { + expect(() => { + new TokensManager({}); + }).to.throw(ArgumentError, 'baseUrl field is required'); }); }); - describe('instance', function() { - var methods = ['getInfo', 'getDelegationToken']; - var manager = new TokensManager(validOptions); + describe('instance', () => { + const methods = ['getInfo', 'getDelegationToken', 'revokeRefreshToken']; + const manager = new TokensManager(validOptions); - methods.forEach(function(methodName) { - it('should have a ' + methodName + ' method', function() { + methods.forEach((methodName) => { + it(`should have a ${methodName} method`, () => { expect(manager[methodName]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#getInfo', function() { - var manager = new TokensManager(validOptions); - var path = '/tokeninfo'; + describe('#getInfo', () => { + const manager = new TokensManager(validOptions); + const path = '/tokeninfo'; - beforeEach(function() { - this.request = nock(BASE_URL) - .post(path) - .reply(200); + beforeEach(function () { + this.request = nock(BASE_URL).post(path).reply(200); }); - it('should require an ID token', function() { - var getInfo = manager.getInfo.bind(manager); + it('should require an ID token', () => { + const getInfo = manager.getInfo.bind(manager); expect(getInfo).to.throw(ArgumentError, 'An ID token is required'); }); - it('should throw an error when the token is invalid', function() { - var getInfo = manager.getInfo.bind(manager, ''); + it('should throw an error when the token is invalid', () => { + const getInfo = manager.getInfo.bind(manager, ''); expect(getInfo).to.throw(ArgumentError, 'The ID token is not valid'); }); - it('should not throw errors when the token is valid', function() { - var getInfo = manager.getInfo.bind(manager, 'VALID_TOKEN'); + it('should not throw errors when the token is valid', () => { + const getInfo = manager.getInfo.bind(manager, 'VALID_TOKEN'); expect(getInfo).to.not.throw(ArgumentError); }); - it('should accept a callback', function(done) { + it('should accept a callback', (done) => { manager.getInfo('VALID_TOKEN', done.bind(null, null)); }); - it('should return a promise when no callback is provided', function() { - var returnValue = manager.getInfo('VALID_TOKEN'); - - expect(returnValue).to.be.an.instanceOf(Promise); + it('should return a promise when no callback is provided', () => { + const returnValue = manager.getInfo('VALID_TOKEN'); + expect(isPromise(returnValue)).ok; }); - it('should not return a promise when a callback is provided', function() { - var returnValue = manager.getInfo('VALID_TOKEN', function() {}); + it('should not return a promise when a callback is provided', () => { + const returnValue = manager.getInfo('VALID_TOKEN', () => {}); expect(returnValue).to.be.undefined; }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; - manager.getInfo('VALID_TOKEN').then(function() { + manager.getInfo('VALID_TOKEN').then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the headers specified in the instance options', function(done) { + it('should include the headers specified in the instance options', (done) => { nock.cleanAll(); - var request = nock(BASE_URL) + const request = nock(BASE_URL) .post(path) .matchHeader('Content-Type', validOptions.headers['Content-Type']) .reply(200); - manager.getInfo('VALID_TOKEN').then(function() { + manager.getInfo('VALID_TOKEN').then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should send the ID token in the body of the request', function(done) { + it('should send the ID token in the body of the request', (done) => { nock.cleanAll(); - var request = nock(BASE_URL) - .post(path, function(body) { - return body.id_token === 'VALID_TOKEN'; - }) + const request = nock(BASE_URL) + .post(path, (body) => body.id_token === 'VALID_TOKEN') .reply(200); - manager.getInfo('VALID_TOKEN').then(function() { + manager.getInfo('VALID_TOKEN').then(() => { expect(request.isDone()).to.be.true; done(); @@ -130,25 +129,23 @@ describe('TokensManager', function() { }); }); - describe('#getDelegationToken', function() { - var path = '/delegation'; - var manager = new TokensManager(validOptions); + describe('#getDelegationToken', () => { + const path = '/delegation'; + const manager = new TokensManager(validOptions); - beforeEach(function() { - this.request = nock(BASE_URL) - .post(path) - .reply(200); + beforeEach(function () { + this.request = nock(BASE_URL).post(path).reply(200); }); - it('should require a data object', function() { - var getDelegationToken = manager.getDelegationToken.bind(manager); + it('should require a data object', () => { + const getDelegationToken = manager.getDelegationToken.bind(manager); expect(getDelegationToken).to.throw(ArgumentError, 'Missing token data object'); }); - it('should require an ID token or refresh token', function() { - var data = {}; - var getDelegationToken = manager.getDelegationToken.bind(manager, data); + it('should require an ID token or refresh token', () => { + const data = {}; + const getDelegationToken = manager.getDelegationToken.bind(manager, data); expect(getDelegationToken).to.throw( ArgumentError, @@ -156,9 +153,9 @@ describe('TokensManager', function() { ); }); - it('should not accept an ID token and a refresh token simulatenously', function() { - var data = { id_token: 'foo', refresh_token: 'bar' }; - var getDelegationToken = manager.getDelegationToken.bind(manager, data); + it('should not accept an ID token and a refresh token simulatenously', () => { + const data = { id_token: 'foo', refresh_token: 'bar' }; + const getDelegationToken = manager.getDelegationToken.bind(manager, data); expect(getDelegationToken).to.throw( ArgumentError, @@ -166,84 +163,83 @@ describe('TokensManager', function() { ); }); - it('should require a target client', function() { - var data = { id_token: 'TEST_ID_TOKEN' }; - var getDelegationToken = manager.getDelegationToken.bind(manager, data); + it('should require a target client', () => { + const data = { id_token: 'TEST_ID_TOKEN' }; + const getDelegationToken = manager.getDelegationToken.bind(manager, data); expect(getDelegationToken).to.throw(ArgumentError, 'target field is required'); }); - it('should require an API type', function() { - var data = { + it('should require an API type', () => { + const data = { id_token: 'TEST_ID_TOKEN', - target: 'TEST_TARGET' + target: 'TEST_TARGET', }; - var getDelegationToken = manager.getDelegationToken.bind(manager, data); + const getDelegationToken = manager.getDelegationToken.bind(manager, data); expect(getDelegationToken).to.throw(ArgumentError, 'api_type field is required'); }); - it('should require an grant type', function() { - var data = { + it('should require an grant type', () => { + const data = { id_token: 'TEST_ID_TOKEN', target: 'TEST_TARGET', - api_type: 'aws' + api_type: 'aws', }; - var getDelegationToken = manager.getDelegationToken.bind(manager, data); + const getDelegationToken = manager.getDelegationToken.bind(manager, data); expect(getDelegationToken).to.throw(ArgumentError, 'grant_type field is required'); }); - it('should accept a callback', function(done) { - var data = { + it('should accept a callback', (done) => { + const data = { id_token: 'TEST_ID_TOKEN', target: 'TEST_TARGET', api_type: 'aws', - grant_type: 'SAMPLE_GRANT_TYPE' + grant_type: 'SAMPLE_GRANT_TYPE', }; manager.getDelegationToken(data, done.bind(null, null)); }); - it('should return a promise when no callback is given', function() { - var data = { + it('should return a promise when no callback is given', () => { + const data = { id_token: 'TEST_ID_TOKEN', target: 'TEST_TARGET', api_type: 'aws', - grant_type: 'SAMPLE_GRANT_TYPE' + grant_type: 'SAMPLE_GRANT_TYPE', }; - var returnValue = manager.getDelegationToken(data); - - expect(returnValue).to.be.an.instanceOf(Promise); + const returnValue = manager.getDelegationToken(data); + expect(isPromise(returnValue)).ok; }); - it('should not return a promise when a callback is given', function() { - var data = { + it('should not return a promise when a callback is given', () => { + const data = { id_token: 'TEST_ID_TOKEN', target: 'TEST_TARGET', api_type: 'aws', - grant_type: 'SAMPLE_GRANT_TYPE' + grant_type: 'SAMPLE_GRANT_TYPE', }; - var returnValue = manager.getDelegationToken(data, function() {}); + const returnValue = manager.getDelegationToken(data, () => {}); expect(returnValue).to.equal(undefined); }); - it('should perform a POST request to ' + path, function() {}); + it(`should perform a POST request to ${path}`, () => {}); - it('should include the data in the body of the request', function(done) { + it('should include the data in the body of the request', (done) => { nock.cleanAll(); - var data = { + const data = { id_token: 'TEST_ID_TOKEN', target: 'TEST_TARGET', api_type: 'aws', - grant_type: 'SAMPLE_GRANT_TYPE' + grant_type: 'SAMPLE_GRANT_TYPE', }; - var request = nock(BASE_URL) - .post(path, function(body) { - for (var property in data) { + const request = nock(BASE_URL) + .post(path, (body) => { + for (const property in data) { if (body[property] !== data[property]) { return false; } @@ -253,76 +249,261 @@ describe('TokensManager', function() { }) .reply(); - manager.getDelegationToken(data).then(function() { + manager.getDelegationToken(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should use the instance client ID if none specified', function(done) { + it('should use the instance client ID if none specified', (done) => { nock.cleanAll(); - var data = { + const data = { id_token: 'TEST_ID_TOKEN', target: 'TEST_TARGET', api_type: 'aws', - grant_type: 'SAMPLE_GRANT_TYPE' + grant_type: 'SAMPLE_GRANT_TYPE', }; - var request = nock(BASE_URL) - .post(path, function(body) { - return body.client_id === validOptions.clientId; - }) + const request = nock(BASE_URL) + .post(path, (body) => body.client_id === validOptions.clientId) .reply(); - manager.getDelegationToken(data).then(function() { + manager.getDelegationToken(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should let the user override the default client ID', function(done) { + it('should let the user override the default client ID', (done) => { nock.cleanAll(); - var data = { + const data = { id_token: 'TEST_ID_TOKEN', target: 'TEST_TARGET', api_type: 'aws', grant_type: 'SAMPLE_GRANT_TYPE', - client_id: 'OVERRIDEN_CLIENT_ID' + client_id: 'OVERRIDEN_CLIENT_ID', }; - var request = nock(BASE_URL) - .post(path, function(body) { - return body.client_id === data.client_id; - }) + const request = nock(BASE_URL) + .post(path, (body) => body.client_id === data.client_id) .reply(); - manager.getDelegationToken(data).then(function() { + manager.getDelegationToken(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the headers specified in the instance options', function(done) { + it('should include the headers specified in the instance options', (done) => { nock.cleanAll(); - var data = { + const data = { id_token: 'TEST_ID_TOKEN', target: 'TEST_TARGET', api_type: 'aws', - grant_type: 'SAMPLE_GRANT_TYPE' + grant_type: 'SAMPLE_GRANT_TYPE', + }; + + const request = nock(BASE_URL) + .post(path) + .matchHeader('Test-Header', validOptions.headers['Test-Header']) + .reply(200); + + manager.getDelegationToken(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#revokeRefreshToken', () => { + const path = '/oauth/revoke'; + const manager = new TokensManager(validOptions); + + beforeEach(function () { + this.request = nock(BASE_URL).post(path).reply(200); + }); + + it('should require a token data object', () => { + const revokeRefreshToken = manager.revokeRefreshToken.bind(manager); + + expect(revokeRefreshToken).to.throw(ArgumentError, 'Missing token data object'); + }); + + it('should require a token property in the token data object', () => { + const data = {}; + const revokeRefreshToken = manager.revokeRefreshToken.bind(manager, data); + + expect(revokeRefreshToken).to.throw(ArgumentError, 'token property is required'); + }); + + it('should require at least a target client ID', () => { + const manager = new TokensManager({ + baseUrl: BASE_URL, + headers: { + 'Content-Type': 'application/json', + 'Test-Header': 'TEST', + }, + }); + + const data = { + token: 'TEST_REFRESH_TOKEN', + }; + + const revokeRefreshToken = manager.revokeRefreshToken.bind(manager, data); + + expect(revokeRefreshToken).to.throw( + ArgumentError, + 'Neither token data client_id property or constructor clientId property has been set' + ); + }); + + it('should accept a callback', (done) => { + const data = { + token: 'TEST_REFRESH_TOKEN', + }; + + manager.revokeRefreshToken(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', () => { + const data = { + token: 'TEST_REFRESH_TOKEN', + }; + const returnValue = manager.revokeRefreshToken(data); + expect(isPromise(returnValue)).ok; + }); + + it('should not return a promise when a callback is given', () => { + const data = { + token: 'TEST_REFRESH_TOKEN', + }; + const returnValue = manager.revokeRefreshToken(data, () => {}); + + expect(returnValue).to.equal(undefined); + }); + + it(`should perform a POST request to ${path}`, () => {}); + + it('should include the data in the body of the request', (done) => { + nock.cleanAll(); + + const data = { + token: 'TEST_REFRESH_TOKEN', + }; + + const request = nock(BASE_URL) + .post(path, (body) => { + for (const property in data) { + if (body[property] !== data[property]) { + return false; + } + } + + return true; + }) + .reply(); + + manager.revokeRefreshToken(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should use the TokensManager instance client ID if none specified', (done) => { + nock.cleanAll(); + + const data = { + token: 'TEST_REFRESH_TOKEN', + }; + + const request = nock(BASE_URL) + .post(path, (body) => body.client_id === validOptions.clientId) + .reply(); + + manager.revokeRefreshToken(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should let the user override the default client ID', (done) => { + nock.cleanAll(); + + const data = { + token: 'TEST_REFRESH_TOKEN', + client_id: 'OVERRIDEN_CLIENT_ID', + }; + + const request = nock(BASE_URL) + .post(path, (body) => body.client_id === data.client_id) + .reply(); + + manager.revokeRefreshToken(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should use the TokensManager instance client secret if none specified', (done) => { + nock.cleanAll(); + + const data = { + token: 'TEST_REFRESH_TOKEN', + }; + + const request = nock(BASE_URL) + .post(path, (body) => body.client_secret === validOptions.clientSecret) + .reply(); + + manager.revokeRefreshToken(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should let the user override the default client secret', (done) => { + nock.cleanAll(); + + const data = { + token: 'TEST_REFRESH_TOKEN', + client_secret: 'OVERRIDEN_CLIENT_SECRET', + }; + + const request = nock(BASE_URL) + .post(path, (body) => body.client_secret === data.client_secret) + .reply(); + + manager.revokeRefreshToken(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the headers specified in the instance options', (done) => { + nock.cleanAll(); + + const data = { + token: 'TEST_REFRESH_TOKEN', }; - var request = nock(BASE_URL) + const request = nock(BASE_URL) .post(path) .matchHeader('Test-Header', validOptions.headers['Test-Header']) .reply(200); - manager.getDelegationToken(data).then(function() { + manager.revokeRefreshToken(data).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/auth/user-profile.tests.js b/test/auth/user-profile.tests.js deleted file mode 100644 index 5f8fd5610..000000000 --- a/test/auth/user-profile.tests.js +++ /dev/null @@ -1,19 +0,0 @@ -var expect = require('chai').expect; -var extend = require('util')._extend; -var nock = require('nock'); - -// Constants. -var SRC_DIR = '../../src'; -var DOMAIN = 'tenant.auth0.com'; -var API_URL = 'https://' + DOMAIN; -var CLIENT_ID = 'TEST_CLIENT_ID'; - -var ArgumentError = require('rest-facade').ArgumentError; -var Authenticator = require(SRC_DIR + '/auth/OAuthAuthenticator'); - -var validOptions = { - domain: DOMAIN, - clientId: CLIENT_ID -}; - -describe('UserProfile', function() {}); diff --git a/test/auth/users-manager.tests.js b/test/auth/users-manager.tests.js index d5815337c..3d9717f39 100644 --- a/test/auth/users-manager.tests.js +++ b/test/auth/users-manager.tests.js @@ -1,97 +1,100 @@ -var expect = require('chai').expect; -var nock = require('nock'); -var Promise = require('bluebird'); +const { expect } = require('chai'); +const nock = require('nock'); -var BASE_URL = 'https://tenant.auth0.com'; -var CLIENT_ID = 'TEST_CLIENT_ID'; +const isPromise = (thing) => thing && typeof thing.then === 'function'; -var ArgumentError = require('rest-facade').ArgumentError; -var UsersManager = require('../../src/auth/UsersManager'); +const BASE_URL = 'https://tenant.auth0.com'; +const CLIENT_ID = 'TEST_CLIENT_ID'; -describe('UsersManager', function() { - var options = { +const { ArgumentError } = require('rest-facade'); +const UsersManager = require('../../src/auth/UsersManager'); + +describe('UsersManager', () => { + const options = { baseUrl: BASE_URL, clientId: CLIENT_ID, headers: { - 'Content-Type': 'application/json' - } + 'Content-Type': 'application/json', + }, }; - afterEach(function() { + afterEach(() => { nock.cleanAll(); }); - describe('#constructor', function() { - it('should require an options object', function() { - expect(UsersManager).to.throw(ArgumentError, 'Missing users manager options'); + describe('#constructor', () => { + it('should require an options object', () => { + expect(() => { + new UsersManager(); + }).to.throw(ArgumentError, 'Missing users manager options'); }); - it('should require a base URL', function() { - expect(UsersManager.bind(null, {})).to.throw(ArgumentError, 'baseUrl field is required'); + it('should require a base URL', () => { + expect(() => { + new UsersManager({}); + }).to.throw(ArgumentError, 'baseUrl field is required'); }); }); - describe('instance', function() { - var manager = new UsersManager(options); - var methods = ['getInfo', 'impersonate']; + describe('instance', () => { + const manager = new UsersManager(options); + const methods = ['getInfo', 'impersonate']; - methods.forEach(function(methodName) { - it('should have a ' + methodName + ' method', function() { + methods.forEach((methodName) => { + it(`should have a ${methodName} method`, () => { expect(manager[methodName]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#getInfo', function() { - var manager = new UsersManager(options); - var path = '/userinfo'; + describe('#getInfo', () => { + const manager = new UsersManager(options); + const path = '/userinfo'; - beforeEach(function() { - this.request = nock(BASE_URL) - .get(path) - .reply(200); + beforeEach(function () { + this.request = nock(BASE_URL).get(path).reply(200); }); - it('should require an access token', function() { - var getInfo = manager.getInfo.bind(manager); + it('should require an access token', () => { + const getInfo = manager.getInfo.bind(manager); expect(getInfo).to.throw(ArgumentError, 'An access token is required'); }); - it('should throw an error when the token is invalid', function() { - var getInfo = manager.getInfo.bind(manager, ''); + it('should throw an error when the token is invalid', () => { + const getInfo = manager.getInfo.bind(manager, ''); expect(getInfo).to.throw(ArgumentError, 'Invalid access token'); }); - it('should not throw errors when the token is valid', function() { - var getInfo = manager.getInfo.bind(manager, 'VALID_TOKEN'); + it('should not throw errors when the token is valid', () => { + const getInfo = manager.getInfo.bind(manager, 'VALID_TOKEN'); expect(getInfo).to.not.throw(ArgumentError); }); - it('should accept a callback', function(done) { + it('should accept a callback', (done) => { manager.getInfo('ACCESS_TOKEN', done.bind(null, null)); }); - it('should not return a promise when a callback is provided', function() { - var returnValue = manager.getInfo('ACCESS_TOKEN', function() {}); + it('should not return a promise when a callback is provided', () => { + const returnValue = manager.getInfo('ACCESS_TOKEN', () => {}); expect(returnValue).to.equal(undefined); }); - it('should return a promise when no callback is provided', function() { - var returnValue = manager.getInfo('ACCESS_TOKEN'); + it('should return a promise when no callback is provided', () => { + const returnValue = manager.getInfo('ACCESS_TOKEN'); - expect(returnValue).to.be.an.instanceOf(Promise); + expect(isPromise(returnValue)).ok; }); - it('should perform a GET request to ' + path, function(done) { - var request = this.request; + it(`should perform a GET request to ${path}`, function (done) { + const { request } = this; manager .getInfo('ACCESS_TOKEN') - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -99,17 +102,17 @@ describe('UsersManager', function() { .catch(done); }); - it('should include the headers specified in the UsersManager options', function(done) { + it('should include the headers specified in the UsersManager options', (done) => { nock.cleanAll(); - var request = nock(BASE_URL) + const request = nock(BASE_URL) .get('/userinfo') .matchHeader('Content-Type', options.headers['Content-Type']) .reply(200); manager .getInfo('ACCESS_TOKEN') - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -117,17 +120,17 @@ describe('UsersManager', function() { .catch(done); }); - it('should send the access token in the Authorization header', function(done) { + it('should send the access token in the Authorization header', (done) => { nock.cleanAll(); - var request = nock(BASE_URL) + const request = nock(BASE_URL) .get('/userinfo') .matchHeader('Authorization', 'Bearer ACCESS_TOKEN') .reply(200); manager .getInfo('ACCESS_TOKEN') - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -136,104 +139,102 @@ describe('UsersManager', function() { }); }); - describe('#impersonate', function() { - var USER_ID = encodeURIComponent('github|12345'); - var token = 'API V1 TOKEN'; - var manager = new UsersManager(options); - var path = '/users/' + USER_ID + '/impersonate'; + describe('#impersonate', () => { + const USER_ID = encodeURIComponent('github|12345'); + const token = 'API V1 TOKEN'; + const manager = new UsersManager(options); + const path = `/users/${USER_ID}/impersonate`; - beforeEach(function() { - this.request = nock(BASE_URL) - .post(path) - .reply(200); + beforeEach(function () { + this.request = nock(BASE_URL).post(path).reply(200); }); - it('should require a user ID', function() { - var impersonate = manager.impersonate.bind(manager); + it('should require a user ID', () => { + const impersonate = manager.impersonate.bind(manager); expect(impersonate).to.throw(ArgumentError, 'You must specify a user ID'); }); - it('should throw an error when the user ID is not valid', function() { - var impersonate = manager.impersonate.bind(manager, ''); + it('should throw an error when the user ID is not valid', () => { + const impersonate = manager.impersonate.bind(manager, ''); expect(impersonate).to.throw(ArgumentError, 'The user ID is not valid'); }); - it('should require the impersonation settings object', function() { - var impersonate = manager.impersonate.bind(manager, USER_ID); + it('should require the impersonation settings object', () => { + const impersonate = manager.impersonate.bind(manager, USER_ID); expect(impersonate).to.throw(ArgumentError, 'Missing impersonation settings object'); }); - it('should require an impersonator ID', function() { - var impersonate = manager.impersonate.bind(manager, USER_ID, {}); + it('should require an impersonator ID', () => { + const impersonate = manager.impersonate.bind(manager, USER_ID, {}); expect(impersonate).to.throw(ArgumentError, 'impersonator_id field is required'); }); - it('should require a token', function() { - var settings = { + it('should require a token', () => { + const settings = { impersonator_id: 'auth0|12345', - protocol: 'oauth2' + protocol: 'oauth2', }; - var impersonate = manager.impersonate.bind(manager, USER_ID, settings); + const impersonate = manager.impersonate.bind(manager, USER_ID, settings); expect(impersonate).to.throw(ArgumentError, 'token field is required'); }); - it('should require a protocol', function() { - var settings = { - impersonator_id: 'auth0|12345' + it('should require a protocol', () => { + const settings = { + impersonator_id: 'auth0|12345', }; - var impersonate = manager.impersonate.bind(manager, USER_ID, settings); + const impersonate = manager.impersonate.bind(manager, USER_ID, settings); expect(impersonate).to.throw(ArgumentError, 'protocol field is required'); }); - it('should accept a callback', function(done) { - var settings = { + it('should accept a callback', (done) => { + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', - token: token + token, }; manager.impersonate(USER_ID, settings, done.bind(null, null)); }); - it('should not return a promise when a callback is provided', function() { - var settings = { + it('should not return a promise when a callback is provided', () => { + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', - token: token + token, }; - var returnValue = manager.impersonate(USER_ID, settings, function() {}); + const returnValue = manager.impersonate(USER_ID, settings, () => {}); expect(returnValue).to.equal(undefined); }); - it('should return a promise when no callback is provided', function() { - var settings = { + it('should return a promise when no callback is provided', () => { + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', - token: token + token, }; - var returnValue = manager.impersonate(USER_ID, settings); + const returnValue = manager.impersonate(USER_ID, settings); - expect(returnValue).to.be.an.instanceOf(Promise); + expect(isPromise(returnValue)).ok; }); - it('should perform a POST request to ' + path, function(done) { - var request = this.request; - var settings = { + it(`should perform a POST request to ${path}`, function (done) { + const { request } = this; + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', - token: token + token, }; manager .impersonate(USER_ID, settings) - .then(function() { + .then(() => { expect(request.isDone()).to.be.true; done(); @@ -241,107 +242,101 @@ describe('UsersManager', function() { .catch(done); }); - it('should use the default client ID', function(done) { + it('should use the default client ID', (done) => { nock.cleanAll(); - var settings = { + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', - token: token + token, }; - var request = nock(BASE_URL) - .post(path, function(body) { - return body.client_id === CLIENT_ID; - }) + const request = nock(BASE_URL) + .post(path, (body) => body.client_id === CLIENT_ID) .reply(200); - manager.impersonate(USER_ID, settings).then(function() { + manager.impersonate(USER_ID, settings).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should allow the user to override the client ID', function(done) { + it('should allow the user to override the client ID', (done) => { nock.cleanAll(); - var settings = { + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', clientId: 'OVERRIDEN_CLIENT_ID', - token: token + token, }; - var request = nock(BASE_URL) - .post(path, function(body) { - return body.client_id === 'OVERRIDEN_CLIENT_ID'; - }) + const request = nock(BASE_URL) + .post(path, (body) => body.client_id === 'OVERRIDEN_CLIENT_ID') .reply(200); - manager.impersonate(USER_ID, settings).then(function() { + manager.impersonate(USER_ID, settings).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should use the default headers', function(done) { + it('should use the default headers', (done) => { nock.cleanAll(); - var settings = { + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', - token: token + token, }; - var request = nock(BASE_URL) + const request = nock(BASE_URL) .post(path) .matchHeader('Content-Type', options.headers['Content-Type']) .reply(200); - manager.impersonate(USER_ID, settings).then(function() { + manager.impersonate(USER_ID, settings).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should use the authorization header', function(done) { + it('should use the authorization header', (done) => { nock.cleanAll(); - var settings = { + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', - token: token + token, }; - var request = nock(BASE_URL) + const request = nock(BASE_URL) .post(path) .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - manager.impersonate(USER_ID, settings).then(function() { + manager.impersonate(USER_ID, settings).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should allow the user to add additional parameters', function(done) { + it('should allow the user to add additional parameters', (done) => { nock.cleanAll(); - var settings = { + const settings = { impersonator_id: 'auth0|12345', protocol: 'oauth2', additionalParameters: { - response_type: 'code' + response_type: 'code', }, - token: token + token, }; - var request = nock(BASE_URL) - .post(path, function(body) { - return body.additionalParameters.response_type === 'code'; - }) + const request = nock(BASE_URL) + .post(path, (body) => body.additionalParameters.response_type === 'code') .reply(200); - manager.impersonate(USER_ID, settings).then(function() { + manager.impersonate(USER_ID, settings).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/auth0-rest-client.tests.js b/test/auth0-rest-client.tests.js index 10721ebfd..96aed2b01 100644 --- a/test/auth0-rest-client.tests.js +++ b/test/auth0-rest-client.tests.js @@ -1,120 +1,316 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); +const sinon = require('sinon'); -var ArgumentError = require('rest-facade').ArgumentError; -var ManagementTokenProvider = require('../src/management/ManagementTokenProvider'); -var Auth0RestClient = require('../src/Auth0RestClient'); +const { ArgumentError, Client } = require('rest-facade'); +const Auth0RestClient = require('../src/Auth0RestClient'); +const proxyquire = require('proxyquire'); -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -describe('Auth0RestClient', function() { - before(function() { +describe('Auth0RestClient', () => { + before(function () { this.providerMock = { - getAccessToken: function() { + getAccessToken() { return Promise.resolve('access_token'); - } + }, }; }); - it('should raise an error when no resource Url is provided', function() { - expect(Auth0RestClient).to.throw(ArgumentError, 'Must provide a Resource Url'); + it('should raise an error when no resource Url is provided', () => { + expect(() => { + new Auth0RestClient(); + }).to.throw(ArgumentError, 'Must provide a Resource Url'); }); - it('should raise an error when resource Url is invalid', function() { - var client = Auth0RestClient.bind(null, ''); - expect(client).to.throw(ArgumentError, 'The provided Resource Url is invalid'); + it('should raise an error when resource Url is invalid', () => { + expect(() => { + new Auth0RestClient(''); + }).to.throw(ArgumentError, 'The provided Resource Url is invalid'); }); - it('should raise an error when no options is provided', function() { - var client = Auth0RestClient.bind(null, '/some-resource'); - expect(client).to.throw(ArgumentError, 'Must provide options'); + it('should raise an error when no options is provided', () => { + expect(() => { + new Auth0RestClient('/some-resource'); + }).to.throw(ArgumentError, 'Must provide options'); }); - it('should accept a callback', function(done) { - nock(API_URL) - .get('/some-resource') - .reply(200, { data: 'value' }); + describe('`get`', () => { + it('should encode params.id on `get` requests', function (done) { + nock(API_URL).get('/some-resource/auth0%7C1234').reply(200, { data: 'value' }); - var options = { - headers: {} - }; - var client = new Auth0RestClient(API_URL + '/some-resource', options, this.providerMock); - client.getAll(function(err, data) { + const options = { + headers: {}, + }; + const client = new Auth0RestClient( + `${API_URL}/some-resource/:id`, + options, + this.providerMock + ); + client.get({ id: 'auth0|1234' }, (err, data) => { + expect(data).to.deep.equal({ data: 'value' }); + done(); + nock.cleanAll(); + }); + }); + it('should not encode other params on `get` requests', function (done) { + nock(API_URL) + .get('/some-resource/1234?otherEncoded=auth0%7C6789&other=foobar') + .reply(200, { data: 'value' }); + + const options = { + headers: {}, + }; + const client = new Auth0RestClient( + `${API_URL}/some-resource/:id`, + options, + this.providerMock + ); + client.get({ id: '1234', other: 'foobar', otherEncoded: 'auth0|6789' }, (err, data) => { + expect(err).to.be.null; + expect(data).to.deep.equal({ data: 'value' }); + done(); + nock.cleanAll(); + }); + }); + it('should accept only a callback', function (done) { + nock(API_URL).get('/some-resource').reply(200, { data: 'value' }); + + const options = { + headers: {}, + }; + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, this.providerMock); + client.get({}, (err, data) => { + expect(data).to.deep.equal({ data: 'value' }); + done(); + nock.cleanAll(); + }); + }); + it('should return a promise if no callback is provided', async function () { + nock(API_URL).get('/some-resource').reply(200, { data: 'value' }); + + const options = { + headers: {}, + }; + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, this.providerMock); + const returnValue = client.get(); + expect(returnValue).instanceOf(Promise); + const data = await returnValue; expect(data).to.deep.equal({ data: 'value' }); - done(); nock.cleanAll(); }); }); - it('should return a promise if no callback is given', function(done) { - nock(API_URL) - .get('/some-resource') - .reply(200, { data: 'value' }); + describe('`patch`', () => { + it('should encode params.id on `patch` requests', function (done) { + nock(API_URL).patch('/some-resource/auth0%7C1234%2F5678').reply(200); + + const client = new Auth0RestClient( + `${API_URL}/some-resource/:id`, + { headers: {} }, + this.providerMock + ); + client.patch({ id: 'auth0|1234/5678' }, { data: 'udpate ' }, (err) => { + expect(err).to.be.null; + done(); + nock.cleanAll(); + }); + }); + }); + + describe('`update`', () => { + it('should encode params.id on `update` requests', function (done) { + nock(API_URL).put('/some-resource/auth0%7C1234%2F5678').reply(200); + + const client = new Auth0RestClient( + `${API_URL}/some-resource/:id`, + { headers: {} }, + this.providerMock + ); + client.update({ id: 'auth0|1234/5678' }, { data: 'udpate ' }, (err) => { + expect(err).to.be.null; + done(); + nock.cleanAll(); + }); + }); + }); + + describe('`delete`', () => { + it('should encode params.id on `delete` requests', function (done) { + nock(API_URL).delete('/some-resource/auth0%7C1234%2F5678').reply(200); + + const client = new Auth0RestClient( + `${API_URL}/some-resource/:id`, + { headers: {} }, + this.providerMock + ); + client.delete({ id: 'auth0|1234/5678' }, (err) => { + expect(err).to.be.null; + done(); + nock.cleanAll(); + }); + }); + }); + + it('should return a promise if no callback is given', async function () { + nock(API_URL).get('/some-resource').reply(200, { data: 'value' }); - var options = { - headers: {} + const options = { + headers: {}, }; - var client = new Auth0RestClient(API_URL + '/some-resource', options, this.providerMock); - client.getAll().then(function(data) { - expect(data).to.deep.equal({ data: 'value' }); + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, this.providerMock); + const data = await client.getAll(); + expect(data).to.deep.equal({ data: 'value' }); + nock.cleanAll(); + }); + + it('should accept a callback and handle errors', (done) => { + const providerMock = { + getAccessToken() { + return Promise.reject(new Error('Some Error')); + }, + }; + + nock(API_URL).get('/some-resource').reply(500); + + const options = { + headers: {}, + }; + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, providerMock); + client.getAll((err) => { + expect(err).to.not.null; + expect(err.message).to.be.equal('Some Error'); done(); nock.cleanAll(); }); }); - it('should accept a callback and handle errors', function(done) { - var providerMock = { - getAccessToken: function() { - return Promise.reject(new Error('Some Error')); - } + it('should accept a callback and handle errors with response headers', (done) => { + const providerMock = { + async getAccessToken() { + return 'fake-token'; + }, }; - nock(API_URL) - .get('/some-resource') - .reply(500); + const errorBody = { error: 'message' }; + nock(API_URL).get('/some-resource').reply(500, errorBody); - var options = { - headers: {} + const options = { + headers: {}, + includeResponseHeaders: true, }; - var client = new Auth0RestClient(API_URL + '/some-resource', options, providerMock); - client.getAll(function(err, data) { + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, providerMock); + client.getAll((err) => { expect(err).to.not.null; - expect(err.message).to.be.equal('Some Error'); + expect(err.message).to.be.equal(JSON.stringify(errorBody)); done(); nock.cleanAll(); }); }); - it('should set access token as Authorization header in options object', function(done) { - nock(API_URL) - .get('/some-resource') - .reply(200); + it('should set access token as Authorization header in options object', async function () { + nock(API_URL).get('/some-resource').reply(200); + + const options = { + headers: {}, + }; + + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, this.providerMock); + await client.getAll(); + expect(client.restClient.options.headers['Authorization']).to.be.equal('Bearer access_token'); + + nock.cleanAll(); + }); + + it('should sanitize error when access token is in authorization header', function (done) { + nock(API_URL).get('/some-resource').reply(401); - var options = { - headers: {} + const options = { + headers: {}, }; - var client = new Auth0RestClient(API_URL + '/some-resource', options, this.providerMock); - client.getAll().then(function(data) { - expect(client.options.headers['Authorization']).to.be.equal('Bearer access_token'); + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, this.providerMock); + client.getAll().catch((err) => { + const originalRequestHeader = err.originalError.response.request._header; + expect(originalRequestHeader.authorization).to.equal('[REDACTED]'); done(); nock.cleanAll(); }); }); - it('should catch error when provider.getAccessToken throws an error', function(done) { - var providerMock = { - getAccessToken: function() { + it('should catch error when provider.getAccessToken throws an error', (done) => { + const providerMock = { + getAccessToken() { return Promise.reject(new Error('Some Error')); - } + }, }; - var client = new Auth0RestClient('/some-resource', {}, providerMock); - client.getAll().catch(function(err) { + const client = new Auth0RestClient('/some-resource', {}, providerMock); + client.getAll().catch((err) => { expect(err).to.not.null; expect(err.message).to.be.equal('Some Error'); done(); }); }); + + it('should include response headers in promise response', async function () { + nock(API_URL).get('/some-resource').reply(200, { data: 'value' }); + + const options = { + includeResponseHeaders: true, + headers: {}, + }; + + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, this.providerMock); + const { data, headers } = await client.getAll(); + expect(data).to.deep.equal({ data: 'value' }); + expect(headers).to.deep.equal({ 'content-type': 'application/json' }); + nock.cleanAll(); + }); + + it('should include response headers in callback response', function (done) { + nock(API_URL).get('/some-resource').reply(200, { data: 'value' }); + + const options = { + includeResponseHeaders: true, + headers: {}, + }; + + const client = new Auth0RestClient(`${API_URL}/some-resource`, options, this.providerMock); + client.getAll((err, { data, headers }) => { + expect(data).to.deep.equal({ data: 'value' }); + expect(headers).to.deep.equal({ 'content-type': 'application/json' }); + nock.cleanAll(); + done(); + }); + }); + + it('should make request with proxy', async function () { + const spy = sinon.spy(); + class MockClient extends Client { + constructor(...args) { + spy(...args); + super(...args); + } + } + const RestClient = proxyquire('../src/Auth0RestClient', { + 'rest-facade': { + Client: MockClient, + }, + }); + nock(API_URL).get('/some-resource').reply(200, { data: 'value' }); + + const options = { + headers: {}, + proxy: 'http://proxy', + }; + + const client = new RestClient(`${API_URL}/some-resource`, options, this.providerMock); + const data = await client.getAll(); + expect(data).to.deep.equal({ data: 'value' }); + sinon.assert.calledWithMatch(spy, 'https://tenant.auth0.com/some-resource', { + proxy: 'http://proxy', + }); + }); }); diff --git a/test/auth0.tests.js b/test/auth0.tests.js index bb22ed825..4e2b81f9b 100644 --- a/test/auth0.tests.js +++ b/test/auth0.tests.js @@ -1,16 +1,15 @@ -var expect = require('chai').expect; +const { expect } = require('chai'); -var auth0 = require('../src'); -var AuthenticationClient = require('../src/auth'); -var ManagementClient = require('../src/management'); -var ManagementTokenProvider = require('../src/management/ManagementTokenProvider'); +const auth0 = require('../src'); +const AuthenticationClient = require('../src/auth'); +const ManagementClient = require('../src/management'); -describe('Auth0 module', function() { - it('should expose the AuthenticationClient', function() { +describe('Auth0 module', () => { + it('should expose the AuthenticationClient', () => { expect(auth0.AuthenticationClient).to.equal(AuthenticationClient); }); - it('should expose the ManagementClient', function() { + it('should expose the ManagementClient', () => { expect(auth0.ManagementClient).to.equal(ManagementClient); }); }); diff --git a/test/constants.js b/test/constants.js index cdb00baab..c89219329 100644 --- a/test/constants.js +++ b/test/constants.js @@ -1,4 +1,4 @@ -var constants = (module.exports = {}); +const constants = (module.exports = {}); constants.BASE_API_URL = 'https://login.auth0.com/api/v2/'; constants.EU_BASE_API_URL = 'https://login.eu.auth0.com/api/v2/'; diff --git a/test/data/theme.json b/test/data/theme.json new file mode 100644 index 000000000..38d23708d --- /dev/null +++ b/test/data/theme.json @@ -0,0 +1,74 @@ +{ + "borders": { + "button_border_radius": 3, + "button_border_weight": 1, + "buttons_style": "rounded", + "input_border_radius": 3, + "input_border_weight": 1, + "inputs_style": "rounded", + "show_widget_shadow": true, + "widget_border_weight": 0, + "widget_corner_radius": 5 + }, + "colors": { + "body_text": "#1e212a", + "error": "#d03c38", + "header": "#1e212a", + "icons": "#65676e", + "input_background": "#ffffff", + "input_border": "#c9cace", + "input_filled_text": "#000000", + "input_labels_placeholders": "#65676e", + "links_focused_components": "#635dff", + "primary_button": "#de7878", + "primary_button_label": "#ffffff", + "secondary_button_border": "#c9cace", + "secondary_button_label": "#1e212a", + "success": "#13a688", + "widget_background": "#ffffff", + "widget_border": "#c9cace" + }, + "fonts": { + "body_text": { + "bold": false, + "size": 87.5 + }, + "buttons_text": { + "bold": false, + "size": 100 + }, + "font_url": "", + "input_labels": { + "bold": false, + "size": 100 + }, + "links": { + "bold": true, + "size": 87.5 + }, + "links_style": "normal", + "reference_text_size": 16, + "subtitle": { + "bold": false, + "size": 87.5 + }, + "title": { + "bold": false, + "size": 150 + } + }, + "page_background": { + "background_color": "#000000", + "background_image_url": "", + "page_layout": "center" + }, + "widget": { + "header_text_alignment": "center", + "logo_height": 52, + "logo_position": "center", + "logo_url": "", + "social_buttons_layout": "bottom" + }, + "themeId": "themeid1", + "displayName": "default theme" +} diff --git a/test/data/users.json b/test/data/users.json index 268c61a24..2131f04ce 100644 --- a/test/data/users.json +++ b/test/data/users.json @@ -3,9 +3,7 @@ "email": "jane.doe@contoso.com", "email_verified": true, "app_metadata": { - "roles": [ - "admin" - ], + "roles": ["admin"], "plan": "premium" }, "user_metadata": { diff --git a/test/errors.tests.js b/test/errors.tests.js new file mode 100644 index 000000000..2bdb339bf --- /dev/null +++ b/test/errors.tests.js @@ -0,0 +1,111 @@ +const { expect } = require('chai'); + +const errors = require('../src/errors'); + +describe('Errors', () => { + describe('sanitizeErrorRequestData', () => { + describe('when passed in error is missing request data and headers', () => { + const error = { response: { request: {} } }; + const redactedError = errors.sanitizeErrorRequestData(error); + + it('should return error', () => { + expect(redactedError).to.equal(error); + }); + }); + + describe('when passed in error has request data', () => { + const error = { + response: { + request: { + _data: { + DATA_SECRET: 'secret', + USER_PASSWORD: 'password', + USER_NAME: 'username', + }, + }, + }, + }; + const redactedError = errors.sanitizeErrorRequestData(error); + const sanitizedData = redactedError.response.request._data; + + it('should return [REDACTED] for DATA_SECRET', () => { + expect(sanitizedData.DATA_SECRET).to.equal('[REDACTED]'); + }); + it('should return [REDACTED] for DATA_SECRET', () => { + expect(sanitizedData.DATA_SECRET).to.equal('[REDACTED]'); + }); + it('should return original value for USER_NAME', () => { + expect(sanitizedData.USER_NAME).to.equal(sanitizedData.USER_NAME); + }); + }); + + describe('when passed in error has header data', () => { + const error = { + response: { + request: { + _header: { + authorization: 'Bearer xyz', + }, + }, + }, + }; + const redactedError = errors.sanitizeErrorRequestData(error); + const sanitizedData = redactedError.response.request._header; + + it('should return [REDACTED] for authorization', () => { + expect(sanitizedData.authorization).to.equal('[REDACTED]'); + }); + }); + }); + + describe('SanitizedError', () => { + const name = 'ErrorName'; + const message = 'message'; + const status = 500; + const requestInfo = { keyA: 'a', keyB: 'b' }; + const originalError = { response: { request: { _data: { secret: 'secretpassword' } } } }; + const sanitizedError = new errors.SanitizedError( + name, + message, + status, + requestInfo, + originalError + ); + + it('should be an instance of the builtin Error', () => { + expect(sanitizedError).to.be.an.instanceof(Error); + }); + + it('should be an instance of its class', () => { + expect(sanitizedError).to.be.an.instanceof(errors.SanitizedError); + }); + + it('should have a name', () => { + expect(sanitizedError.name).to.eql(name); + }); + + it('should have a message', () => { + expect(sanitizedError.message).to.eql(message); + }); + + it('should have a statusCode', () => { + expect(sanitizedError.statusCode).to.eql(status); + }); + + it('should have request info', () => { + expect(sanitizedError.requestInfo).to.deep.eql(requestInfo); + }); + + it('should have the original error', () => { + expect(sanitizedError.originalError).to.eql(originalError); + }); + + it('should redact the original error sensitive information', () => { + expect(sanitizedError.originalError.response.request._data.secret).to.eql('[REDACTED]'); + }); + + it('should have a stack with the message and location the error was created', () => { + expect(sanitizedError.stack).to.exist; + }); + }); +}); diff --git a/test/idToken.tests.js b/test/idToken.tests.js new file mode 100644 index 000000000..2ed53b3b9 --- /dev/null +++ b/test/idToken.tests.js @@ -0,0 +1,285 @@ +const assert = require('assert'); +const { expect } = require('chai'); +const jws = require('jws'); +const idToken = require('../src/auth/idToken'); + +const secretHMAC = 'secret'; +//openssl genrsa -out private.pem 2048 +//openssl rsa -in private.pem -pubout -out public.pem +const privateKeyRSA = `-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC4ZtdaIrd1BPIJ +tfnF0TjIK5inQAXZ3XlCrUlJdP+XHwIRxdv1FsN12XyMYO/6ymLmo9ryoQeIrsXB +XYqlET3zfAY+diwCb0HEsVvhisthwMU4gZQu6TYW2s9LnXZB5rVtcBK69hcSlA2k +ZudMZWxZcj0L7KMfO2rIvaHw/qaVOE9j0T257Z8Kp2CLF9MUgX0ObhIsdumFRLaL +DvDUmBPr2zuh/34j2XmWwn1yjN/WvGtdfhXW79Ki1S40HcWnygHgLV8sESFKUxxQ +mKvPUTwDOIwLFL5WtE8Mz7N++kgmDcmWMCHc8kcOIu73Ta/3D4imW7VbKgHZo9+K +3ESFE3RjAgMBAAECggEBAJTEIyjMqUT24G2FKiS1TiHvShBkTlQdoR5xvpZMlYbN +tVWxUmrAGqCQ/TIjYnfpnzCDMLhdwT48Ab6mQJw69MfiXwc1PvwX1e9hRscGul36 +ryGPKIVQEBsQG/zc4/L2tZe8ut+qeaK7XuYrPp8bk/X1e9qK5m7j+JpKosNSLgJj +NIbYsBkG2Mlq671irKYj2hVZeaBQmWmZxK4fw0Istz2WfN5nUKUeJhTwpR+JLUg4 +ELYYoB7EO0Cej9UBG30hbgu4RyXA+VbptJ+H042K5QJROUbtnLWuuWosZ5ATldwO +u03dIXL0SH0ao5NcWBzxU4F2sBXZRGP2x/jiSLHcqoECgYEA4qD7mXQpu1b8XO8U +6abpKloJCatSAHzjgdR2eRDRx5PMvloipfwqA77pnbjTUFajqWQgOXsDTCjcdQui +wf5XAaWu+TeAVTytLQbSiTsBhrnoqVrr3RoyDQmdnwHT8aCMouOgcC5thP9vQ8Us +rVdjvRRbnJpg3BeSNimH+u9AHgsCgYEA0EzcbOltCWPHRAY7B3Ge/AKBjBQr86Kv +TdpTlxePBDVIlH+BM6oct2gaSZZoHbqPjbq5v7yf0fKVcXE4bSVgqfDJ/sZQu9Lp +PTeV7wkk0OsAMKk7QukEpPno5q6tOTNnFecpUhVLLlqbfqkB2baYYwLJR3IRzboJ +FQbLY93E8gkCgYB+zlC5VlQbbNqcLXJoImqItgQkkuW5PCgYdwcrSov2ve5r/Acz +FNt1aRdSlx4176R3nXyibQA1Vw+ztiUFowiP9WLoM3PtPZwwe4bGHmwGNHPIfwVG +m+exf9XgKKespYbLhc45tuC08DATnXoYK7O1EnUINSFJRS8cezSI5eHcbQKBgQDC +PgqHXZ2aVftqCc1eAaxaIRQhRmY+CgUjumaczRFGwVFveP9I6Gdi+Kca3DE3F9Pq +PKgejo0SwP5vDT+rOGHN14bmGJUMsX9i4MTmZUZ5s8s3lXh3ysfT+GAhTd6nKrIE +kM3Nh6HWFhROptfc6BNusRh1kX/cspDplK5x8EpJ0QKBgQDWFg6S2je0KtbV5PYe +RultUEe2C0jYMDQx+JYxbPmtcopvZQrFEur3WKVuLy5UAy7EBvwMnZwIG7OOohJb +vkSpADK6VPn9lbqq7O8cTedEHttm6otmLt8ZyEl3hZMaL3hbuRj6ysjmoFKx6CrX +rK0/Ikt5ybqUzKCMJZg2VKGTxg== +-----END PRIVATE KEY-----`; + +//base date expressed in MS +//expected values for a good id token payload +const expectations = { + clientId: 'tokens-test-123', + clientIdAlt: 'external-test-999', + issuer: 'https://tokens-test.auth0.com/', + nonce: 'a1b2c3d4e5', + clock: Date.now(), +}; + +//date helpers +const TODAY_IN_SECONDS = Math.floor(expectations.clock / 1000); +const ONE_DAY_IN_SECONDS = 3600 * 24; +function yesterday() { + return TODAY_IN_SECONDS - ONE_DAY_IN_SECONDS; +} +function tomorrow() { + return TODAY_IN_SECONDS + ONE_DAY_IN_SECONDS; +} +//good id token payload +const payload = { + iss: expectations.issuer, + sub: 'auth0|123456789', + aud: [expectations.clientId, expectations.clientIdAlt], + exp: tomorrow(), + iat: yesterday(), + nonce: expectations.nonce, + azp: expectations.clientId, + org_id: 'test|org', + auth_time: TODAY_IN_SECONDS, +}; + +const defaultOptions = { + issuer: expectations.issuer, + audience: [expectations.clientId, expectations.clientIdAlt], + nonce: expectations.nonce, +}; + +function generateJWT(bodyOverrides, alg) { + const body = Object.assign({}, payload, bodyOverrides || {}); + alg = alg || 'RS256'; + const options = { + header: { alg }, + payload: body, + }; + if (alg === 'RS256') { + options.privateKey = privateKeyRSA; + } else if (alg === 'HS256') { + options.secret = secretHMAC; + } + return jws.sign(options); +} + +describe('idToken.decode', () => { + it('should decode a valid token', () => { + const alg = 'RS256'; + const token = generateJWT({ name: 'ÁÁutf8' }, alg); + const decoded = idToken.decode(token); + + assert.equal(decoded._raw, token); + assert.equal(decoded.header.alg, alg); + + Object.keys(payload).forEach((key) => { + assert.deepEqual(payload[key], decoded.payload[key]); + }); + }); + + it('throws errors on invalid tokens', () => { + const IDTOKEN_ERROR_MESSAGE = 'ID token could not be decoded'; + + it('throws when there is more or less than 3 parts', () => { + assert.throws(idToken.decode('test'), IDTOKEN_ERROR_MESSAGE); + assert.throws(idToken.decode('test.'), IDTOKEN_ERROR_MESSAGE); + assert.throws(idToken.decode('test.test'), IDTOKEN_ERROR_MESSAGE); + assert.throws(idToken.decode('test.test.test.test'), IDTOKEN_ERROR_MESSAGE); + }); + it('throws when there is no header', () => { + assert.throws(idToken.decode('.test.test'), IDTOKEN_ERROR_MESSAGE); + }); + it('throws when there is no payload', () => { + assert.throws(idToken.decode('test..test'), IDTOKEN_ERROR_MESSAGE); + }); + it('throws when there is no signature', () => { + assert.throws(idToken.decode('test.test.'), IDTOKEN_ERROR_MESSAGE); + }); + }); +}); + +describe('idToken.validate', () => { + let expectedOptions; + + beforeEach(() => { + expectedOptions = Object.assign({}, defaultOptions); + expectedOptions.audience = expectations.clientId; + expectedOptions.maxAge = 123; + }); + + it('should throw when no id token is present', () => { + expect(() => { + idToken.validate(); + }).to.throw('ID token is required but missing'); + }); + it('should throw when no Issuer is present in the claim', () => { + expect(() => { + idToken.validate(generateJWT({ iss: undefined })); + }).to.throw('Issuer (iss) claim must be a string present in the ID token'); + }); + it('should throw when the expected issuer is not in the claim', () => { + expect(() => { + idToken.validate(generateJWT({}), { issuer: 'ExpectedIssuer' }); + }).to.throw( + 'Issuer (iss) claim mismatch in the ID token; expected "ExpectedIssuer", found "https://tokens-test.auth0.com/"' + ); + }); + it('should throw when the claim has no Subject', () => { + expect(() => { + idToken.validate(generateJWT({ sub: undefined }), defaultOptions); + }).to.throw('Subject (sub) claim must be a string present in the ID token'); + }); + it('should throw when the alg is neither rs256 or hs256', () => { + const token = + 'eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJodHRwczovL3Rva2Vucy10ZXN0LmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHwxMjM0NTY3ODkiLCJhdWQiOiJ0b2tlbnMtdGVzdC0xMjMifQ.cZ4qDwoKdKQx8DtD-F-xVKCxd3rz58wSJh3k28z5qnpzm4x3xRiyHCuUvtxmL2aPdBQ37Zt8Mt5drd9hZhNzFQ'; + + expect(() => { + idToken.validate(token, defaultOptions); + }).to.throw( + 'Signature algorithm of "HS512" is not supported. Expected the ID token to be signed with "RS256" or "HS256".' + ); + }); + it('should throw when the audience is not a string or array', () => { + expect(() => { + idToken.validate(generateJWT({ aud: undefined }), defaultOptions); + }).to.throw( + 'Audience (aud) claim must be a string or array of strings present in the ID token' + ); + }); + it('should throw when claim audience is a String and not expected audience', () => { + expect(() => { + idToken.validate(generateJWT({ aud: 'notExpected' }), expectedOptions); + }).to.throw( + 'Audience (aud) claim mismatch in the ID token; expected "tokens-test-123" but found "notExpected"' + ); + }); + it('should throw when claim audience is an Array and not expected audience', () => { + expect(() => { + idToken.validate(generateJWT({ aud: ['notExpected'] }), expectedOptions); + }).to.throw( + 'Audience (aud) claim mismatch in the ID token; expected "tokens-test-123" but was not one of "notExpected"' + ); + }); + it('should throw when expected audience is not a String or Array', () => { + expect(() => { + idToken.validate(generateJWT({ aud: 10000 }), expectedOptions); + }).to.throw( + 'Audience (aud) claim must be a string or array of strings present in the ID token' + ); + expect(() => { + idToken.validate(generateJWT({ aud: {} }), expectedOptions); + }).to.throw( + 'Audience (aud) claim must be a string or array of strings present in the ID token' + ); + }); + it('should throw when azp claim not found when aud has multiple values', () => { + expect(() => { + idToken.validate(generateJWT({ azp: undefined }), expectedOptions); + }).to.throw( + 'Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values' + ); + }); + it('should throw when azp claim doesnt match the expected aud', () => { + expectedOptions.audience = expectations.clientIdAlt; + + expect(() => { + idToken.validate(generateJWT({}), expectedOptions); + }).to.throw( + 'Authorized Party (azp) claim mismatch in the ID token; expected "external-test-999", found "tokens-test-123"' + ); + }); + it('should throw when nonce is in options, but missing from claim', () => { + expect(() => { + idToken.validate(generateJWT({ nonce: undefined }), expectedOptions); + }).to.throw('Nonce (nonce) claim must be a string present in the ID token'); + }); + it('should throw when nonce claim doesnt match nonce expected', () => { + expectedOptions.nonce = 'noncey'; + + expect(() => { + idToken.validate(generateJWT({ nonce: 'notExpectedNonce' }), expectedOptions); + }).to.throw( + 'Nonce (nonce) claim mismatch in the ID token; expected "noncey", found "notExpectedNonce"' + ); + }); + it('should throw when nonce claim is not a string', () => { + expect(() => { + idToken.validate(generateJWT({ nonce: 10000 }), expectedOptions); + }).to.throw('Nonce (nonce) claim must be a string present in the ID token'); + expect(() => { + idToken.validate(generateJWT({ nonce: {} }), expectedOptions); + }).to.throw('Nonce (nonce) claim must be a string present in the ID token'); + }); + it('should throw when auth_time is not a number', () => { + expect(() => { + idToken.validate(generateJWT({ auth_time: undefined }), expectedOptions); + }).to.throw( + 'Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified' + ); + }); + it('should throw when exp is not a number', () => { + expect(() => { + idToken.validate(generateJWT({ exp: 'not a number' }), expectedOptions); + }).to.throw('Expiration Time (exp) claim must be a number present in the ID token'); + }); + it('should throw when exp has passed', () => { + expect(() => { + idToken.validate(generateJWT({ exp: yesterday() }), expectedOptions); + }).to.throw('is after expiration time'); + }); + it('should throw when idtoken indicates too much time has passed', () => { + expect(() => { + idToken.validate(generateJWT({ auth_time: yesterday() }), expectedOptions); + }).to.throw( + 'Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication.' + ); + }); + it('should throw when organization is in options, but org_id missing from claim', () => { + expectedOptions.organization = 'testorg'; + + expect(() => { + idToken.validate(generateJWT({ org_id: undefined }), expectedOptions); + }).to.throw('Organization Id (org_id) claim must be a string present in the ID token'); + }); + it('should throw when org claim doesnt match org expected', () => { + expectedOptions.organization = 'testorg'; + + expect(() => { + idToken.validate(generateJWT({ org_id: 'notExpectedOrg' }), expectedOptions); + }).to.throw( + 'Organization Id (org_id) claim value mismatch in the ID token; expected "testorg", found "notExpectedOrg' + ); + }); + it('should NOT throw when org_id matches expected organization', () => { + expectedOptions.organization = 'testorg'; + + expect(() => { + idToken.validate(generateJWT({ org_id: 'testorg' }), expectedOptions); + }).not.to.throw(); + }); +}); diff --git a/test/management/actions.tests.js b/test/management/actions.tests.js new file mode 100644 index 000000000..9e56109fd --- /dev/null +++ b/test/management/actions.tests.js @@ -0,0 +1,1042 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenant.auth0.com'; + +const ActionsManager = require(`../../src/management/ActionsManager`); +const { ArgumentError } = require('rest-facade'); + +describe('ActionsManager', () => { + before(function () { + this.token = 'TOKEN'; + this.actions = new ActionsManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = [ + 'get', + 'getAll', + 'create', + 'update', + 'delete', + 'deploy', + 'test', + 'getVersions', + 'getVersion', + 'createVersion', + 'deployVersion', + 'getAllTriggers', + 'getTriggerBindings', + 'updateTriggerBindings', + ]; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.actions[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new ActionsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new ActionsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new ActionsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#actions', () => { + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/actions/actions').reply(200); + }); + + it('should accept a callback', function (done) { + this.actions.getAll(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/actions/actions').reply(500); + + this.actions.getAll().catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const data = [{ test: true }]; + nock(API_URL).get('/actions/actions').reply(200, data); + + this.actions.getAll().then((credentials) => { + expect(credentials).to.be.an.instanceOf(Array); + + expect(credentials.length).to.equal(data.length); + + expect(credentials[0].test).to.equal(data[0].test); + + done(); + }); + }); + + it('should perform a GET request', function (done) { + const { request } = this; + + this.actions.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/actions/actions') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const params = { + include_fields: true, + fields: 'test', + }; + const request = nock(API_URL).get('/actions/actions').query(params).reply(200); + + this.actions.getAll(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#get', () => { + beforeEach(function () { + this.data = { + id: '0d565aa1-d8ce-4802-83e7-82e3d2040222', + name: 'Test Action', + supported_triggers: [ + { + id: 'post-login', + version: 'v1', + }, + ], + required_configuration: [], + required_secrets: [], + created_at: '2020-07-29T19:45:15.725999098Z', + updated_at: '2020-07-29T19:45:15.725999098Z', + }; + + this.request = nock(API_URL).get(`/actions/actions/${this.data.id}`).reply(200, this.data); + }); + + it('should accept a callback', function (done) { + const params = { id: this.data.id }; + + this.actions.get(params, done.bind(null, null)); + }); + + it('should be backwards compatible with action_id', function (done) { + const params = { action_id: this.data.id }; + + this.actions.get(params, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions + .get({ id: this.data.id }) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request', function (done) { + const { request } = this; + + this.actions.get({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/actions/actions${this.data.id}`).reply(500); + + this.actions.get({ id: this.data.id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/actions/actions/${this.data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.get({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#create', () => { + const data = { + name: 'my-action-13', + supported_triggers: [ + { + id: 'post-login', + version: 'v1', + }, + ], + }; + + beforeEach(function () { + this.request = nock(API_URL).post('/actions/actions').reply(201); + }); + + it('should accept a callback', function (done) { + this.actions.create(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post('/actions/actions/').reply(500); + + this.actions.create(data).catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should perform a POST request', function (done) { + const { request } = this; + + this.actions.create(data).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).post('/actions/actions', data).reply(200); + + this.actions.create(data).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post('/actions/actions') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#update', () => { + beforeEach(function () { + this.data = { id: 'ACTION_ID' }; + + this.request = nock(API_URL) + .patch(`/actions/actions/${this.data.id}`, { name: 'my-new-action-name' }) + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.actions.update( + { id: 'ACTION_ID' }, + { name: 'my-new-action-name' }, + done.bind(null, null) + ); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions + .update({ id: 'ACTION_ID' }, { name: 'my-new-action-name' }) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PATCH request', function (done) { + const { request } = this; + + this.actions.update({ id: 'ACTION_ID' }, { name: 'my-new-action-name' }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch(`/actions/actions/${this.data.id}`, { name: 'my-new-action-name' }) + .reply(200); + + this.actions.update({ id: 'ACTION_ID' }, { name: 'my-new-action-name' }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/actions/actions/${this.data.id}`).reply(500); + + this.actions.update({ id: this.data.id }, { name: 'my-new-action-name' }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + }); + + describe('#deploy', () => { + const action_id = 'action-id-1'; + + beforeEach(function () { + this.request = nock(API_URL).post(`/actions/actions/${action_id}/deploy`).reply(200); + }); + + it('should accept a callback', function (done) { + this.actions.deploy({ action_id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.actions.deploy({ action_id }).then(done.bind(null, null)); + }); + + it(`should perform a post request${action_id}`, function (done) { + const { request } = this; + + this.actions.deploy({ action_id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/actions/actions/${action_id}/deploy`).reply(500); + + this.actions.deploy({ action_id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/actions/actions/${action_id}/deploy`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.deploy({ action_id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#test', () => { + const action_id = 'action-id-1'; + const payload = { event: {} }; + + beforeEach(function () { + this.request = nock(API_URL).post(`/actions/actions/${action_id}/test`).reply(200); + }); + + it('should accept a callback', function (done) { + this.actions.test({ action_id }, { payload }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.actions.test({ action_id }, { payload }).then(done.bind(null, null)); + }); + + it(`should perform a post request${action_id}`, function (done) { + const { request } = this; + + this.actions.test({ action_id }, { payload }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/actions/actions/${action_id}/test`).reply(500); + + this.actions.test({ action_id }, { payload }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/actions/actions/${action_id}/test`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.test({ action_id }, { payload }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#delete', () => { + const action_id = 'action-id-1'; + + beforeEach(function () { + this.request = nock(API_URL).delete(`/actions/actions/${action_id}`).reply(200); + }); + + it('should accept a callback', function (done) { + this.actions.delete({ action_id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.actions.delete({ action_id }).then(done.bind(null, null)); + }); + + it(`should perform a delete request${action_id}`, function (done) { + const { request } = this; + + this.actions.delete({ action_id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete(`/actions/actions/${action_id}`).reply(500); + + this.actions.delete({ action_id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/actions/actions/${action_id}`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.delete({ action_id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + }); + + describe('action versions', () => { + describe('#getVersions', () => { + beforeEach(function () { + nock.cleanAll(); + + this.data = { + id: '0d565aa1-d8ce-4802-83e7-82e3d2040222', + }; + + this.request = nock(API_URL) + .get(`/actions/actions/${this.data.id}/versions`) + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + const params = { id: this.data.id }; + + this.actions.getVersions(params, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions + .get({ id: this.data.id }) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request', function (done) { + const { request } = this; + + this.actions.getVersions({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/actions/actions/${this.data.id}/versions`).reply(500); + + this.actions.getVersions({ id: this.data.id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/actions/actions/${this.data.id}/versions`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.getVersions({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getVersion', () => { + beforeEach(function () { + nock.cleanAll(); + + this.data = { + id: '0d565aa1-d8ce-4802-83e7-82e3d2040222', + versionId: '7asd8sd9-d8ce-4802-83e7-82e3d2040222', + }; + + this.request = nock(API_URL) + .get(`/actions/actions/${this.data.id}/versions/${this.data.versionId}`) + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + const params = { id: this.data.id, version_id: this.data.versionId }; + + this.actions.getVersion(params, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions + .get({ id: this.data.id, version_id: this.data.versionId }) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request', function (done) { + const { request } = this; + + this.actions.getVersion({ id: this.data.id, version_id: this.data.versionId }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL) + .get(`/actions/actions/${this.data.id}/versions/${this.data.versionId}`) + .reply(500); + + this.actions + .getVersion({ id: this.data.id, version_id: this.data.versionId }) + .catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/actions/actions/${this.data.id}/versions/${this.data.versionId}`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.getVersion({ id: this.data.id, version_id: this.data.versionId }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#createVersion', () => { + beforeEach(function () { + nock.cleanAll(); + + this.data = { + id: '0d565aa1-d8ce-4802-83e7-82e3d2040222', + }; + + this.request = nock(API_URL) + .post(`/actions/actions/${this.data.id}/versions`) + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + const params = { id: this.data.id }; + + this.actions.createVersion(params, this.data, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions + .createVersion({ id: this.data.id }, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a POST request', function (done) { + const { request } = this; + + this.actions.createVersion({ id: this.data.id }, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/actions/actions/${this.data.id}/versions`).reply(500); + + this.actions.createVersion({ id: this.data.id }, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/actions/actions/${this.data.id}/versions`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.createVersion({ id: this.data.id }, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#deployVersion', () => { + const action_id = 'action-id-1'; + const version_id = 'action-version-id-1'; + + beforeEach(function () { + this.request = nock(API_URL) + .post(`/actions/actions/${action_id}/versions/${version_id}/deploy`) + .reply(200); + }); + + it('should accept a callback', function (done) { + this.actions.deployVersion({ action_id, version_id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.actions.deployVersion({ action_id, version_id }).then(done.bind(null, null)); + }); + + it('should perform a post request', function (done) { + const { request } = this; + + this.actions.deployVersion({ action_id, version_id, update_draft: true }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL) + .post(`/actions/actions/${action_id}/versions/${version_id}/deploy`) + .reply(500); + + this.actions.deployVersion({ action_id, version_id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/actions/actions/${action_id}/deploy`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.deploy({ action_id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + }); + + describe('executions', () => { + describe('#getExecution', () => { + beforeEach(function () { + this.data = { + id: '0d565aa1-d8ce-4802-83e7', + name: 'Execution', + }; + + this.request = nock(API_URL).get(`/actions/executions/${this.data.id}`).reply(200); + }); + + it('should accept a callback', function (done) { + const params = { execution_id: this.data.id }; + + this.actions.getExecution(params, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions + .getExecution({ execution_id: this.data.id }) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request', function (done) { + const { request } = this; + + this.actions + .getExecution({ execution_id: this.data.id }) + .then(() => { + expect(request.isDone()).to.be.true; + + done(); + }) + .catch((err) => { + console.log(err); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/actions/executions/${this.data.id}`).reply(500); + + this.actions.getExecution({ execution_id: this.data.id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/actions/executions/${this.data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.getExecution({ execution_id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + }); + + describe('triggers', () => { + const params = { per_page: 2 }; + describe('#getAllTriggers', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/actions/triggers').reply(200); + }); + + it('should accept a callback', function (done) { + this.actions.getAllTriggers(params, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions.getAllTriggers().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/actions/triggers').reply(500); + + this.actions.getAllTriggers().catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const data = [{ trigger1: 'rigger1' }]; + nock(API_URL).get('/actions/triggers').reply(200, data); + + this.actions.getAllTriggers().then((triggers) => { + expect(triggers).to.be.an.instanceOf(Array); + + expect(triggers.length).to.equal(data.length); + + expect(triggers[0].trigger1).to.equal(data[0].trigger1); + + done(); + }); + }); + + it('should perform a GET request', function (done) { + const { request } = this; + + this.actions.getAllTriggers().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/actions/triggers') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.actions.getAllTriggers().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const params = { + include_fields: true, + fields: 'test', + }; + const request = nock(API_URL).get('/actions/triggers').query(params).reply(200); + + this.actions.getAllTriggers(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateTriggerBindings', () => { + const trigger_id = 'post-login'; + + beforeEach(function () { + this.data = { bindings: [] }; + + this.request = nock(API_URL) + .patch(`/actions/triggers/${trigger_id}/bindings`) + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.actions.updateTriggerBindings({ trigger_id }, this.data, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions + .updateTriggerBindings({ trigger_id }, this.data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PATCH request', function (done) { + const { request } = this; + + this.actions.updateTriggerBindings({ trigger_id }, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).patch(`/actions/triggers/${trigger_id}/bindings`).reply(200); + + this.actions.updateTriggerBindings({ trigger_id }, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/actions/triggers/${trigger_id}/bindings`).reply(500); + + this.actions.updateTriggerBindings({ trigger_id }, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + }); + + describe('#getTriggerBindings', () => { + const trigger_id = 'post-login'; + + beforeEach(function () { + this.data = { bindings: {} }; + + this.request = nock(API_URL) + .get(`/actions/triggers/${trigger_id}/bindings`) + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.actions.getTriggerBindings({ trigger_id }, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.actions + .getTriggerBindings({ trigger_id }) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request', function (done) { + const { request } = this; + + this.actions.getTriggerBindings({ trigger_id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).get(`/actions/triggers/${trigger_id}/bindings`).reply(200); + + this.actions.getTriggerBindings({ trigger_id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/actions/triggers/${trigger_id}/bindings`).reply(500); + + this.actions.getTriggerBindings({ trigger_id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + }); + }); +}); diff --git a/test/management/attack-protection.tests.js b/test/management/attack-protection.tests.js new file mode 100644 index 000000000..9977cb822 --- /dev/null +++ b/test/management/attack-protection.tests.js @@ -0,0 +1,520 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const SRC_DIR = '../../src'; +const API_URL = 'https://tenant.auth0.com'; + +const AttackProtectionManager = require(`${SRC_DIR}/management/AttackProtectionManager`); +const { ArgumentError } = require('rest-facade'); + +describe('AttackProtectionManager', () => { + const bruteForcePath = '/attack-protection/brute-force-protection'; + const suspiciousIpPath = '/attack-protection/suspicious-ip-throttling'; + const breachedPasswordDetectionPath = '/attack-protection/breached-password-detection'; + + before(function () { + this.token = 'TOKEN'; + this.attackProtection = new AttackProtectionManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = [ + 'getBruteForceConfig', + 'updateBruteForceConfig', + 'getSuspiciousIpThrottlingConfig', + 'updateSuspiciousIpThrottlingConfig', + 'getBreachedPasswordDetectionConfig', + 'updateBreachedPasswordDetectionConfig', + ]; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.attackProtection[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => new AttackProtectionManager()).to.throw( + ArgumentError, + 'Must provide manager options' + ); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => new AttackProtectionManager({})).to.throw( + ArgumentError, + 'Must provide a base URL for the API' + ); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => new AttackProtectionManager({ baseUrl: '' })).to.throw( + ArgumentError, + 'The provided base URL is invalid' + ); + }); + }); + + describe('Brute Force Protection', () => { + const data = { + enabled: true, + shields: ['user_notification', 'block'], + mode: 'count_per_identifier_and_ip', + allowlist: ['1.1.2.2'], + max_attempts: 100, + }; + + describe('#getBruteForceConfig', () => { + beforeEach(function () { + this.request = nock(API_URL).get(bruteForcePath).reply(200, data); + }); + + it('should accept a callback', function (done) { + this.attackProtection.getBruteForceConfig({}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.attackProtection + .getBruteForceConfig() + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(bruteForcePath).reply(500); + + this.attackProtection.getBruteForceConfig().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + this.attackProtection.getBruteForceConfig().then((bruteForceConfig) => { + expect(bruteForceConfig).to.deep.equal(data); + + done(); + }); + }); + + it(`should perform a GET request to /api/v2${bruteForcePath}`, function (done) { + const { request } = this; + + this.attackProtection.getBruteForceConfig().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(bruteForcePath) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.attackProtection.getBruteForceConfig().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateBruteForceConfig', () => { + beforeEach(function () { + this.request = nock(API_URL).patch(bruteForcePath).reply(200, data); + }); + + it('should accept a callback', function (done) { + this.attackProtection.updateBruteForceConfig({}, data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.attackProtection + .updateBruteForceConfig({}, data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(bruteForcePath).reply(500); + + this.attackProtection.updateBruteForceConfig({}, data).catch((err) => { + expect(err).to.exist.to.be.an.instanceOf(Error); + + done(); + }); + }); + + it(`should perform a PATCH request to /api/v2${bruteForcePath}`, function (done) { + const { request } = this; + + this.attackProtection.updateBruteForceConfig({}, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + const { request } = this; + + this.attackProtection.updateBruteForceConfig({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + this.attackProtection.updateBruteForceConfig({}, data).then((bruteForceConfig) => { + expect(bruteForceConfig).to.deep.equal(data); + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch(bruteForcePath) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.attackProtection.updateBruteForceConfig({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + }); + + describe('Suspicious IP Throttling', () => { + const data = { + enabled: true, + shields: ['admin_notification', 'block'], + allowlist: ['1.1.1.0'], + stage: { + 'pre-login': { + max_attempts: 1, + rate: 864000, + }, + 'pre-user-registration': { + max_attempts: 1, + rate: 864000, + }, + }, + }; + + describe('#getSuspiciousIpThrottlingConfig', () => { + beforeEach(function () { + this.request = nock(API_URL).get(suspiciousIpPath).reply(200, data); + }); + + it('should accept a callback', function (done) { + this.attackProtection.getSuspiciousIpThrottlingConfig({}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.attackProtection + .getSuspiciousIpThrottlingConfig() + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(suspiciousIpPath).reply(500); + + this.attackProtection.getSuspiciousIpThrottlingConfig().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + this.attackProtection + .getSuspiciousIpThrottlingConfig() + .then((suspiciousIpThrottlingConfig) => { + expect(suspiciousIpThrottlingConfig).to.deep.equal(data); + + done(); + }); + }); + + it(`should perform a GET request to /api/v2${suspiciousIpPath}`, function (done) { + const { request } = this; + + this.attackProtection.getSuspiciousIpThrottlingConfig().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(suspiciousIpPath) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.attackProtection.getSuspiciousIpThrottlingConfig().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateSuspiciousIpThrottlingConfig', () => { + beforeEach(function () { + this.request = nock(API_URL).patch(suspiciousIpPath).reply(200, data); + }); + + it('should accept a callback', function (done) { + this.attackProtection.updateSuspiciousIpThrottlingConfig({}, data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.attackProtection + .updateSuspiciousIpThrottlingConfig({}, data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(suspiciousIpPath).reply(500); + + this.attackProtection.updateSuspiciousIpThrottlingConfig({}, data).catch((err) => { + expect(err).to.exist.to.be.an.instanceOf(Error); + + done(); + }); + }); + + it(`should perform a PATCH request to /api/v2${suspiciousIpPath}`, function (done) { + const { request } = this; + + this.attackProtection.updateSuspiciousIpThrottlingConfig({}, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + const { request } = this; + + this.attackProtection.updateSuspiciousIpThrottlingConfig({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + this.attackProtection + .updateSuspiciousIpThrottlingConfig({}, data) + .then((suspiciousIpThrottlingConfig) => { + expect(suspiciousIpThrottlingConfig).to.deep.equal(data); + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch(suspiciousIpPath) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.attackProtection.updateSuspiciousIpThrottlingConfig({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + }); + + describe('Breached Password Detection', () => { + const data = { + enabled: true, + shields: ['block', 'user_notification', 'admin_notification'], + admin_notification_frequency: ['immediately'], + }; + + describe('#getBreachedPasswordDetectionConfig', () => { + beforeEach(function () { + this.request = nock(API_URL).get(breachedPasswordDetectionPath).reply(200, data); + }); + + it('should accept a callback', function (done) { + this.attackProtection.getBreachedPasswordDetectionConfig({}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.attackProtection + .getBreachedPasswordDetectionConfig() + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(breachedPasswordDetectionPath).reply(500); + + this.attackProtection.getBreachedPasswordDetectionConfig().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + this.attackProtection + .getBreachedPasswordDetectionConfig() + .then((breachedPasswordDetectionConfig) => { + expect(breachedPasswordDetectionConfig).to.deep.equal(data); + + done(); + }); + }); + + it(`should perform a GET request to /api/v2${breachedPasswordDetectionPath}`, function (done) { + const { request } = this; + + this.attackProtection.getBreachedPasswordDetectionConfig().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(breachedPasswordDetectionPath) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.attackProtection.getBreachedPasswordDetectionConfig().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateBreachedPasswordDetectionConfig', () => { + beforeEach(function () { + this.request = nock(API_URL).patch(breachedPasswordDetectionPath).reply(200, data); + }); + + it('should accept a callback', function (done) { + this.attackProtection.updateBreachedPasswordDetectionConfig({}, data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.attackProtection + .updateBreachedPasswordDetectionConfig({}, data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(breachedPasswordDetectionPath).reply(500); + + this.attackProtection.updateBreachedPasswordDetectionConfig({}, data).catch((err) => { + expect(err).to.exist.to.be.an.instanceOf(Error); + + done(); + }); + }); + + it(`should perform a PATCH request to /api/v2${breachedPasswordDetectionPath}`, function (done) { + const { request } = this; + + this.attackProtection.updateBreachedPasswordDetectionConfig({}, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + const { request } = this; + + this.attackProtection.updateBreachedPasswordDetectionConfig({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + this.attackProtection + .updateBreachedPasswordDetectionConfig({}, data) + .then((breachedPasswordDetectionConfig) => { + expect(breachedPasswordDetectionConfig).to.deep.equal(data); + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch(breachedPasswordDetectionPath) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.attackProtection.updateBreachedPasswordDetectionConfig({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + }); +}); diff --git a/test/management/blacklisted-tokens.tests.js b/test/management/blacklisted-tokens.tests.js index 45e95eb75..c683798c1 100644 --- a/test/management/blacklisted-tokens.tests.js +++ b/test/management/blacklisted-tokens.tests.js @@ -1,91 +1,83 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var BlacklistedTokensManager = require(SRC_DIR + '/management/BlacklistedTokensManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const BlacklistedTokensManager = require(`../../src/management/BlacklistedTokensManager`); +const { ArgumentError } = require('rest-facade'); -describe('BlacklistedTokensManager', function() { - before(function() { +describe('BlacklistedTokensManager', () => { + before(function () { this.token = 'TOKEN'; this.blacklistedTokens = new BlacklistedTokensManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['add', 'getAll']; + describe('instance', () => { + const methods = ['add', 'getAll']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.blacklistedTokens[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(BlacklistedTokensManager).to.throw(ArgumentError, 'Must provide client options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new BlacklistedTokensManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = BlacklistedTokensManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new BlacklistedTokensManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = BlacklistedTokensManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new BlacklistedTokensManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/blacklists/tokens') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/blacklists/tokens').reply(200); }); - it('should accept a callback', function(done) { - this.blacklistedTokens.getAll(function() { + it('should accept a callback', function (done) { + this.blacklistedTokens.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.blacklistedTokens - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.blacklistedTokens.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/blacklists/tokens') - .reply(500); + nock(API_URL).get('/blacklists/tokens').reply(500); - this.blacklistedTokens.getAll().catch(function(err) { + this.blacklistedTokens.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/blacklists/tokens') - .reply(200, data); + const data = [{ test: true }]; + nock(API_URL).get('/blacklists/tokens').reply(200, data); - this.blacklistedTokens.getAll().then(function(blacklistedTokens) { + this.blacklistedTokens.getAll().then((blacklistedTokens) => { expect(blacklistedTokens).to.be.an.instanceOf(Array); expect(blacklistedTokens.length).to.equal(data.length); @@ -96,117 +88,111 @@ describe('BlacklistedTokensManager', function() { }); }); - it('should perform a GET request to /api/v2/blacklists/tokens', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/blacklists/tokens', function (done) { + const { request } = this; - this.blacklistedTokens.getAll().then(function() { + this.blacklistedTokens.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/blacklists/tokens') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.blacklistedTokens.getAll().then(function() { + this.blacklistedTokens.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/blacklists/tokens') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.blacklistedTokens.getAll({ include_fields: true, fields: 'test' }).then(function() { + this.blacklistedTokens.getAll({ include_fields: true, fields: 'test' }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); }); - describe('#add', function() { - var tokenData = { + describe('#add', () => { + const tokenData = { aud: '', - jti: '' + jti: '', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/blacklists/tokens') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/blacklists/tokens').reply(200); }); - it('should accept a callback', function(done) { - this.blacklistedTokens.add(tokenData, function() { + it('should accept a callback', function (done) { + this.blacklistedTokens.add(tokenData, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.blacklistedTokens .add(tokenData) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/blacklists/tokens') - .reply(500); + nock(API_URL).post('/blacklists/tokens').reply(500); - this.blacklistedTokens.add(tokenData).catch(function(err) { + this.blacklistedTokens.add(tokenData).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/blacklists/tokens', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/blacklists/tokens', function (done) { + const { request } = this; - this.blacklistedTokens.add(tokenData).then(function() { + this.blacklistedTokens.add(tokenData).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the token data in the body of the request', function(done) { + it('should pass the token data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/blacklists/tokens', tokenData) - .reply(200); + const request = nock(API_URL).post('/blacklists/tokens', tokenData).reply(200); - this.blacklistedTokens.add(tokenData).then(function() { + this.blacklistedTokens.add(tokenData).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/blacklists/tokens') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.blacklistedTokens.add(tokenData).then(function() { + this.blacklistedTokens.add(tokenData).then(() => { expect(request.isDone()).to.be.true; done(); }); diff --git a/test/management/branding.tests.js b/test/management/branding.tests.js new file mode 100644 index 000000000..813d84d61 --- /dev/null +++ b/test/management/branding.tests.js @@ -0,0 +1,749 @@ +const { expect } = require('chai'); +const fs = require('fs'); +const path = require('path'); +const nock = require('nock'); +const util = require('util'); + +const API_URL = 'https://tenant.auth0.com'; + +const BrandingManager = require(`../../src/management/BrandingManager`); +const { ArgumentError } = require('rest-facade'); + +describe('BrandingManager', () => { + let branding, token; + + before(function () { + this.token = 'TOKEN'; + this.branding = new BrandingManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + ({ branding, token } = this); + }); + + describe('instance', () => { + const methods = [ + 'getSettings', + 'updateSettings', + 'getTheme', + 'getDefaultTheme', + 'createTheme', + 'updateTheme', + 'deleteTheme', + ]; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.branding[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new BrandingManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new BrandingManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new BrandingManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#getSettings', () => { + const data = { + colors: { + primary: '#FFF', + }, + favicon_url: 'https://example.com/favicon.ico', + logo_url: 'https://example.com/logo.png', + font: { + url: 'https://example.com/font.ttf', + }, + }; + + beforeEach(function () { + this.request = nock(API_URL).get('/branding').reply(200); + }); + + it('should accept a callback', function (done) { + this.branding.getSettings(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.branding.getSettings().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/branding').reply(500); + + this.branding.getSettings().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/branding').reply(200, data); + + this.branding.getSettings().then((provider) => { + expect(provider.id).to.equal(data.id); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/branding', function (done) { + const { request } = this; + + this.branding.getSettings().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/branding') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.branding.getSettings().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const params = { + include_fields: true, + fields: 'test', + }; + + const request = nock(API_URL).get('/branding').query(params).reply(200); + + this.branding.getSettings(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateSettings', () => { + const data = { + colors: { + primary: '#FFF', + }, + favicon_url: 'https://example.com/favicon.ico', + logo_url: 'https://example.com/logo.png', + font: { + url: 'https://example.com/font.ttf', + }, + }; + + beforeEach(function () { + this.request = nock(API_URL).patch('/branding').reply(200, data); + }); + + it('should accept a callback', function (done) { + this.branding.updateSettings({}, data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.branding + .updateSettings({}, data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/branding/${data.id}`).reply(500); + + this.branding.updateSettings({}, data).catch((err) => { + expect(err).to.exist.to.be.an.instanceOf(Error); + + done(); + }); + }); + + it('should perform a PATCH request to /api/v2/branding', function (done) { + const { request } = this; + + this.branding.updateSettings({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).patch('/branding', data).reply(200); + + this.branding.updateSettings({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch('/branding') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.branding.updateSettings({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getUniversalLoginTemplate', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/branding/templates/universal-login').reply(200); + }); + + afterEach(() => { + nock.cleanAll(); + }); + + it('should accept a callback', function (done) { + this.branding.getUniversalLoginTemplate(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.branding + .getUniversalLoginTemplate() + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/branding/templates/universal-login').reply(500); + + this.branding.getUniversalLoginTemplate().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + const data = { body: 'test' }; + + nock.cleanAll(); + + nock(API_URL).get('/branding/templates/universal-login').reply(200, data); + + this.branding.getUniversalLoginTemplate().then((response) => { + expect(response.body).to.equal(data.body); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/branding', function (done) { + const { request } = this; + + this.branding.getUniversalLoginTemplate().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/branding/templates/universal-login') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.branding.getUniversalLoginTemplate().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#setUniversalLoginTemplate', () => { + beforeEach(function () { + this.request = nock(API_URL).put('/branding/templates/universal-login').reply(200); + }); + + afterEach(() => { + nock.cleanAll(); + }); + + it('should accept a callback', function (done) { + this.branding.setUniversalLoginTemplate({}, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.branding + .setUniversalLoginTemplate({}, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).put('/branding/templates/universal-login').reply(500); + + this.branding.setUniversalLoginTemplate({}, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + const data = { body: 'test' }; + + nock.cleanAll(); + + nock(API_URL).put('/branding/templates/universal-login').reply(200, data); + + this.branding.setUniversalLoginTemplate({}, data).then((response) => { + expect(response.body).to.equal(data.body); + + done(); + }); + }); + + it('should perform a PUT request to /api/v2/branding/templates/universal-login', function (done) { + const { request } = this; + + this.branding.setUniversalLoginTemplate({}, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put('/branding/templates/universal-login') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.branding.setUniversalLoginTemplate({}, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#deleteUniversalLoginTemplate', () => { + beforeEach(function () { + this.request = nock(API_URL).delete('/branding/templates/universal-login').reply(200); + }); + + afterEach(() => { + nock.cleanAll(); + }); + + it('should accept a callback', function (done) { + this.branding.deleteUniversalLoginTemplate(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.branding + .deleteUniversalLoginTemplate() + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete('/branding/templates/universal-login').reply(500); + + this.branding.deleteUniversalLoginTemplate().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + const data = { body: 'test' }; + + nock.cleanAll(); + + nock(API_URL).delete('/branding/templates/universal-login').reply(200, data); + + this.branding.deleteUniversalLoginTemplate().then((response) => { + expect(response.body).to.equal(data.body); + + done(); + }); + }); + + it('should perform a DELETE request to /api/v2/branding/templates/universal-login', function (done) { + const { request } = this; + + this.branding.deleteUniversalLoginTemplate().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete('/branding/templates/universal-login') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.branding.deleteUniversalLoginTemplate().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getTheme', () => { + beforeEach(() => {}); + + it('should accept a callback', (done) => { + nock(API_URL).get('/branding/themes/themeid1').reply(200); + + branding.getTheme({ id: 'themeid1' }, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', async () => { + nock(API_URL).get('/branding/themes/themeid1').reply(200); + + const promise = branding.getTheme({ id: 'themeid1' }); + expect(promise.then).to.exist; + expect(promise.catch).to.exist; + await promise; + }); + + it('should pass any errors to the promise catch handler', async () => { + nock(API_URL).get('/branding/themes/themeid1').reply(404); + + try { + await branding.getTheme({ id: 'themeid1' }); + } catch (err) { + expect(err.statusCode).to.eq(404); + expect(err).to.exist; + } + }); + + it('should pass the body of the response to the "then" handler', async () => { + const data = JSON.parse( + await util.promisify(fs.readFile)(path.join(__dirname, '../data/theme.json')) + ); + nock(API_URL).get('/branding/themes/themeid1').reply(200, data); + + const theme = await branding.getTheme({ id: 'themeid1' }); + expect(theme.themeId).to.equal(data.themeId); + }); + + it('should perform a GET request to /api/v2/branding/themes/:theme_id', async () => { + const request = nock(API_URL).get('/branding/themes/themeid1').reply(200); + + await branding.getTheme({ id: 'themeid1' }); + expect(request.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async () => { + const request = nock(API_URL) + .get('/branding/themes/themeid1') + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200, { id: 1 }); + + await branding.getTheme({ id: 'themeid1' }); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#getDefaultTheme', () => { + beforeEach(() => {}); + + it('should accept a callback', (done) => { + nock(API_URL).get('/branding/themes/default').reply(200); + + branding.getDefaultTheme(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', async () => { + nock(API_URL).get('/branding/themes/default').reply(200); + + const promise = branding.getDefaultTheme(); + expect(promise.then).to.exist; + expect(promise.catch).to.exist; + await promise; + }); + + it('should pass any errors to the promise catch handler', async () => { + nock(API_URL).get('/branding/themes/default').reply(404); + + try { + await branding.getDefaultTheme(); + } catch (err) { + expect(err.statusCode).to.eq(404); + expect(err).to.exist; + } + }); + + it('should pass the body of the response to the "then" handler', async () => { + const data = JSON.parse( + await util.promisify(fs.readFile)(path.join(__dirname, '../data/theme.json')) + ); + nock(API_URL).get('/branding/themes/default').reply(200, data); + + const theme = await branding.getDefaultTheme(); + expect(theme.themeId).to.equal(data.themeId); + }); + + it('should perform a GET request to /api/v2/branding/themes/default', async () => { + const request = nock(API_URL).get('/branding/themes/default').reply(200); + + await branding.getDefaultTheme(); + expect(request.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async () => { + const request = nock(API_URL) + .get('/branding/themes/default') + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200, { id: 1 }); + + await branding.getDefaultTheme(); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#createTheme', () => { + let data; + beforeEach(async () => { + data = JSON.parse( + await util.promisify(fs.readFile)(path.join(__dirname, '../data/theme.json')) + ); + }); + + it('should accept a callback', (done) => { + nock(API_URL).post(`/branding/themes`, data).reply(201); + + branding.createTheme(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', async () => { + nock(API_URL).post(`/branding/themes`, data).reply(201); + + const promise = branding.createTheme(data); + expect(promise.then).to.exist; + expect(promise.catch).to.exist; + await promise; + }); + + it('should pass any errors to the promise catch handler', async () => { + nock(API_URL).post(`/branding/themes`, data).reply(409); + + try { + await branding.createTheme(data); + } catch (err) { + expect(err.statusCode).to.eq(409); + expect(err).to.exist; + } + }); + + it('should pass the body of the response to the "then" handler', async () => { + nock(API_URL).post(`/branding/themes`, data).reply(201, data); + + const theme = await branding.createTheme(data); + expect(theme.themeId).to.equal(data.themeId); + }); + + it('should perform a POST request to /branding/themes', async () => { + const request = nock(API_URL).post(`/branding/themes`, data).reply(201, data); + + await branding.createTheme(data); + expect(request.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async () => { + const request = nock(API_URL) + .post('/branding/themes', data) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(201, data); + + await branding.createTheme(data); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#updateTheme', () => { + let data, themeId, params; + beforeEach(async () => { + ({ themeId, ...data } = JSON.parse( + await util.promisify(fs.readFile)(path.join(__dirname, '../data/theme.json')) + )); + params = { id: themeId }; + }); + + it('should accept a callback', (done) => { + nock(API_URL).patch(`/branding/themes/${themeId}`, data).reply(200); + + branding.updateTheme(params, data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', async () => { + nock(API_URL).patch(`/branding/themes/${themeId}`, data).reply(200); + + const promise = branding.updateTheme(params, data); + expect(promise.then).to.exist; + expect(promise.catch).to.exist; + await promise; + }); + + it('should pass any errors to the promise catch handler', async () => { + nock(API_URL).patch(`/branding/themes/${themeId}`, data).reply(404); + + try { + await branding.updateTheme(params, data); + } catch (err) { + expect(err.statusCode).to.eq(404); + expect(err).to.exist; + } + }); + + it('should pass the body of the response to the "then" handler', async () => { + nock(API_URL).patch(`/branding/themes/${themeId}`, data).reply(200, data); + + const theme = await branding.updateTheme(params, data); + expect(theme.themeId).to.equal(data.themeId); + }); + + it('should perform a PATCH request to /api/v2/branding/themes/:theme_id', async () => { + const request = nock(API_URL).patch(`/branding/themes/${themeId}`, data).reply(200, data); + + await branding.updateTheme(params, data); + expect(request.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async () => { + const request = nock(API_URL) + .patch(`/branding/themes/${themeId}`, data) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200, data); + + await branding.updateTheme(params, data); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#deleteTheme', () => { + let themeId, params; + beforeEach(async () => { + themeId = 'themeid1'; + params = { id: themeId }; + }); + + it('should accept a callback', (done) => { + nock(API_URL).delete(`/branding/themes/${themeId}`).reply(204); + + branding.deleteTheme(params, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', async () => { + nock(API_URL).delete(`/branding/themes/${themeId}`).reply(204); + + const promise = branding.deleteTheme(params); + expect(promise.then).to.exist; + expect(promise.catch).to.exist; + await promise; + }); + + it('should pass any errors to the promise catch handler', async () => { + nock(API_URL).delete(`/branding/themes/${themeId}`).reply(404); + + try { + await branding.deleteTheme(params); + } catch (err) { + expect(err.statusCode).to.eq(404); + expect(err).to.exist; + } + }); + + it('should perform a PATCH request to /api/v2/branding/themes/:theme_id', async () => { + const request = nock(API_URL).delete(`/branding/themes/${themeId}`).reply(204); + + await branding.deleteTheme(params); + expect(request.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async () => { + const request = nock(API_URL) + .delete(`/branding/themes/${themeId}`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(204); + + await branding.deleteTheme(params); + expect(request.isDone()).to.be.true; + }); + }); +}); diff --git a/test/management/client-grants.tests.js b/test/management/client-grants.tests.js index 08a27ca52..d55a13d05 100644 --- a/test/management/client-grants.tests.js +++ b/test/management/client-grants.tests.js @@ -1,98 +1,89 @@ -var expect = require('chai').expect; -var nock = require('nock'); -var Promise = require('bluebird'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var ClientGrantsManager = require(SRC_DIR + '/management/ClientGrantsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const ClientGrantsManager = require(`../../src/management/ClientGrantsManager`); +const { ArgumentError } = require('rest-facade'); -describe('ClientGrantsManager', function() { - before(function() { +describe('ClientGrantsManager', () => { + before(function () { this.token = 'TOKEN'; this.grants = new ClientGrantsManager({ headers: { - authorization: 'Bearer ' + this.token + authorization: `Bearer ${this.token}`, }, - baseUrl: API_URL + baseUrl: API_URL, }); }); - afterEach(function() { + afterEach(() => { nock.cleanAll(); }); - describe('instance', function() { - var methods = ['getAll', 'create', 'update', 'delete']; + describe('instance', () => { + const methods = ['getAll', 'create', 'update', 'delete']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.grants[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(ClientGrantsManager).to.throw(ArgumentError, 'Must provide client options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new ClientGrantsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var grants = ClientGrantsManager.bind(null, {}); - - expect(grants).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new ClientGrantsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var grants = ClientGrantsManager.bind(null, { baseUrl: '' }); - - expect(grants).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new ClientGrantsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/client-grants') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/client-grants').reply(200); }); - it('should accept a callback', function(done) { - this.grants.getAll(function() { + it('should accept a callback', function (done) { + this.grants.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.grants - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.grants.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/client-grants') - .reply(500); + nock(API_URL).get('/client-grants').reply(500); - this.grants.getAll().catch(function(err) { + this.grants.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/client-grants') - .reply(200, data); + const data = [{ test: true }]; + nock(API_URL).get('/client-grants').reply(200, data); - this.grants.getAll().then(function(grants) { + this.grants.getAll().then((grants) => { expect(grants).to.be.an.instanceOf(Array); expect(grants.length).to.equal(data.length); @@ -103,104 +94,97 @@ describe('ClientGrantsManager', function() { }); }); - it('should perform a GET request to /api/v2/client-grants', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/client-grants', function (done) { + const { request } = this; - this.grants.getAll().then(function() { + this.grants.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/client-grants') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.grants.getAll().then(function() { + this.grants.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/client-grants') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.grants.getAll({ include_fields: true, fields: 'test' }).then(function() { + this.grants.getAll({ include_fields: true, fields: 'test' }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); }); - describe('#create', function() { - var data = { + describe('#create', () => { + const data = { client_id: 'CLIENT_ID', audience: 'AUDIENCE', - scope: ['user'] + scope: ['user'], }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/client-grants') - .reply(201, data); + beforeEach(function () { + this.request = nock(API_URL).post('/client-grants').reply(201, data); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.grants.create(data, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { - this.grants - .create(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.grants.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/client-grants', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/client-grants', function (done) { + const { request } = this; - this.grants.create(data).then(function() { + this.grants.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/client-grants') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(201, data); - this.grants.create(data).then(function() { + this.grants.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new client grant data in the request body', function(done) { + it('should include the new client grant data in the request body', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/client-grants', data) - .reply(201, data); + const request = nock(API_URL).post('/client-grants', data).reply(201, data); - this.grants.create(data).then(function() { + this.grants.create(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -208,44 +192,37 @@ describe('ClientGrantsManager', function() { }); }); - describe('#update', function() { - beforeEach(function() { + describe('#update', () => { + beforeEach(function () { this.data = { id: 5 }; - this.request = nock(API_URL) - .patch('/client-grants/' + this.data.id) - .reply(200, this.data); + this.request = nock(API_URL).patch(`/client-grants/${this.data.id}`).reply(200, this.data); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.grants.update({ id: 5 }, {}, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { - this.grants - .update({ id: 5 }, {}) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.grants.update({ id: 5 }, {}).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a PATCH request to /api/v2/client-grants/5', function(done) { - var request = this.request; + it('should perform a PATCH request to /api/v2/client-grants/5', function (done) { + const { request } = this; - this.grants.update({ id: 5 }, {}).then(function() { + this.grants.update({ id: 5 }, {}).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/client-grants/' + this.data.id, this.data) - .reply(200); + const request = nock(API_URL).patch(`/client-grants/${this.data.id}`, this.data).reply(200); - this.grants.update({ id: 5 }, this.data).then(function() { + this.grants.update({ id: 5 }, this.data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -253,27 +230,25 @@ describe('ClientGrantsManager', function() { }); }); - describe('#delete', function() { - var id = 5; + describe('#delete', () => { + const id = 5; - beforeEach(function() { - this.request = nock(API_URL) - .delete('/client-grants/' + id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).delete(`/client-grants/${id}`).reply(200); }); - it('should accept a callback', function(done) { - this.grants.delete({ id: id }, done.bind(null, null)); + it('should accept a callback', function (done) { + this.grants.delete({ id }, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { - this.grants.delete({ id: id }).then(done.bind(null, null)); + it('should return a promise when no callback is given', function (done) { + this.grants.delete({ id }).then(done.bind(null, null)); }); - it('should perform a DELETE request to /client-grants/' + id, function(done) { - var request = this.request; + it(`should perform a DELETE request to /client-grants/${id}`, function (done) { + const { request } = this; - this.grants.delete({ id: id }).then(function() { + this.grants.delete({ id }).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/management/client.tests.js b/test/management/client.tests.js index e3325c277..001e80f84 100644 --- a/test/management/client.tests.js +++ b/test/management/client.tests.js @@ -1,98 +1,95 @@ -var expect = require('chai').expect; -var nock = require('nock'); -var Promise = require('bluebird'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var ClientsManager = require(SRC_DIR + '/management/ClientsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const ClientsManager = require(`../../src/management/ClientsManager`); +const { ArgumentError } = require('rest-facade'); -describe('ClientsManager', function() { - before(function() { +/** + * @type {ClientsManager} + */ + +let clients; + +describe('ClientsManager', () => { + before(function () { this.token = 'TOKEN'; - this.clients = new ClientsManager({ + clients = new ClientsManager({ headers: { - authorization: 'Bearer ' + this.token + authorization: `Bearer ${this.token}`, }, - baseUrl: API_URL + baseUrl: API_URL, }); }); - afterEach(function() { + afterEach(() => { nock.cleanAll(); }); - describe('instance', function() { - var methods = ['getAll', 'get', 'create', 'update', 'delete']; + describe('instance', () => { + const methods = ['getAll', 'get', 'create', 'update', 'delete']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { - expect(this.clients[method]).to.exist.to.be.an.instanceOf(Function); + methods.forEach((method) => { + it(`should have a ${method} method`, () => { + expect(clients[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(ClientsManager).to.throw(ArgumentError, 'Must provide client options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new ClientsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = ClientsManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new ClientsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = ClientsManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new ClientsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/clients') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/clients').reply(200); }); - it('should accept a callback', function(done) { - this.clients.getAll(function() { + it('should accept a callback', (done) => { + clients.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.clients - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', (done) => { + clients.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', (done) => { nock.cleanAll(); - var request = nock(API_URL) - .get('/clients') - .reply(500); + nock(API_URL).get('/clients').reply(500); - this.clients.getAll().catch(function(err) { + clients.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', (done) => { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/clients') - .reply(200, data); + const data = [{ test: true }]; + nock(API_URL).get('/clients').reply(200, data); - this.clients.getAll().then(function(clients) { + clients.getAll().then((clients) => { expect(clients).to.be.an.instanceOf(Array); expect(clients.length).to.equal(data.length); @@ -103,100 +100,93 @@ describe('ClientsManager', function() { }); }); - it('should perform a GET request to /api/v2/clients', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/clients', function (done) { + const { request } = this; - this.clients.getAll().then(function() { + clients.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/clients') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.clients.getAll().then(function() { + clients.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', (done) => { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/clients') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.clients.getAll({ include_fields: true, fields: 'test' }).then(function() { + clients.getAll({ include_fields: true, fields: 'test' }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); }); - describe('#create', function() { - var data = { name: 'Test client' }; + describe('#create', () => { + const data = { name: 'Test client' }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/clients') - .reply(201, data); + beforeEach(function () { + this.request = nock(API_URL).post('/clients').reply(201, data); }); - it('should accept a callback', function(done) { - this.clients.create(data, done.bind(null, null)); + it('should accept a callback', (done) => { + clients.create(data, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { - this.clients - .create(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', (done) => { + clients.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/clients', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/clients', function (done) { + const { request } = this; - this.clients.create(data).then(function() { + clients.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/clients') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(201, data); - this.clients.create(data).then(function() { + clients.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new client data in the request body', function(done) { + it('should include the new client data in the request body', (done) => { nock.cleanAll(); - var request = nock(API_URL) - .post('/clients', data) - .reply(201, data); + const request = nock(API_URL).post('/clients', data).reply(201, data); - this.clients.create(data).then(function() { + clients.create(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -204,36 +194,31 @@ describe('ClientsManager', function() { }); }); - describe('#get', function() { - beforeEach(function() { + describe('#get', () => { + beforeEach(function () { this.data = { id: 5, name: 'John Doe', - email: 'john@doe.com' + email: 'john@doe.com', }; - this.request = nock(API_URL) - .get('/clients/' + this.data.id) - .reply(201, this.data); + this.request = nock(API_URL).get(`/clients/${this.data.id}`).reply(201, this.data); }); - it('should accept a callback', function(done) { - var params = { id: this.data.id }; + it('should accept a callback', function (done) { + const params = { id: this.data.id }; - this.clients.get(params, done.bind(null, null)); + clients.get(params, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { - this.clients - .get({ id: this.data.id }) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + clients.get({ id: this.data.id }).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/clients/5', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/clients/5', function (done) { + const { request } = this; - this.clients.get({ client_id: this.data.id }).then(function() { + clients.get({ client_id: this.data.id }).then(() => { expect(request.isDone()).to.be.true; done(); @@ -241,44 +226,37 @@ describe('ClientsManager', function() { }); }); - describe('#update', function() { - beforeEach(function() { + describe('#update', () => { + beforeEach(function () { this.data = { id: 5 }; - this.request = nock(API_URL) - .patch('/clients/' + this.data.id) - .reply(200, this.data); + this.request = nock(API_URL).patch(`/clients/${this.data.id}`).reply(200, this.data); }); - it('should accept a callback', function(done) { - this.clients.update({ client_id: 5 }, {}, done.bind(null, null)); + it('should accept a callback', (done) => { + clients.update({ client_id: 5 }, {}, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { - this.clients - .update({ client_id: 5 }, {}) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', (done) => { + clients.update({ client_id: 5 }, {}).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a PATCH request to /api/v2/clients/5', function(done) { - var request = this.request; + it('should perform a PATCH request to /api/v2/clients/5', function (done) { + const { request } = this; - this.clients.update({ client_id: 5 }, {}).then(function() { + clients.update({ client_id: 5 }, {}).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/clients/' + this.data.id, this.data) - .reply(200); + const request = nock(API_URL).patch(`/clients/${this.data.id}`, this.data).reply(200); - this.clients.update({ client_id: 5 }, this.data).then(function() { + clients.update({ client_id: 5 }, this.data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -286,31 +264,88 @@ describe('ClientsManager', function() { }); }); - describe('#delete', function() { - var id = 5; + describe('#delete', () => { + const id = 5; - beforeEach(function() { - this.request = nock(API_URL) - .delete('/clients/' + id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).delete(`/clients/${id}`).reply(200); + }); + + it('should accept a callback', (done) => { + clients.delete({ client_id: id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', (done) => { + clients.delete({ client_id: id }).then(done.bind(null, null)); + }); + + it(`should perform a DELETE request to /clients/${id}`, function (done) { + const { request } = this; + + clients.delete({ client_id: id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); }); + }); - it('should accept a callback', function(done) { - this.clients.delete({ client_id: id }, done.bind(null, null)); + describe('#rotateSecret', () => { + const client_id = 5; + + beforeEach(function () { + this.request = nock(API_URL).post(`/clients/${client_id}/rotate-secret`).reply(200); }); - it('should return a promise when no callback is given', function(done) { - this.clients.delete({ client_id: id }).then(done.bind(null, null)); + it('should accept a callback', (done) => { + clients.rotateClientSecret({ client_id }, done.bind(null, null)); }); - it('should perform a DELETE request to /clients/' + id, function(done) { - var request = this.request; + it('should return a promise if no callback is given', (done) => { + clients + .rotateClientSecret({ client_id }, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); - this.clients.delete({ client_id: id }).then(function() { + it('should perform a POST request to /api/v2/clients/5/rotate-secret', function (done) { + const { request } = this; + + clients.rotateClientSecret({ client_id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); + + it('should return an error when client_id is not sent', () => { + expect(() => { + clients.rotateClientSecret({}); + }).to.throw(ArgumentError, 'The client_id cannot be null or undefined'); + }); + + it('should include the new data in the body of the request', (done) => { + nock.cleanAll(); + + const request = nock(API_URL).post(`/clients/${client_id}/rotate-secret`).reply(200); + + clients.rotateClientSecret({ client_id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).post(`/clients/${client_id}/rotate-secret`).reply(500); + + clients.rotateClientSecret({ client_id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); }); }); diff --git a/test/management/connections.tests.js b/test/management/connections.tests.js index a0764ca1f..998247503 100644 --- a/test/management/connections.tests.js +++ b/test/management/connections.tests.js @@ -1,92 +1,84 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var ConnectionsManager = require(SRC_DIR + '/management/ConnectionsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const ConnectionsManager = require(`../../src/management/ConnectionsManager`); +const { ArgumentError } = require('rest-facade'); -describe('ConnectionsManager', function() { - before(function() { +describe('ConnectionsManager', () => { + before(function () { this.token = 'TOKEN'; this.connections = new ConnectionsManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['getAll', 'get', 'create', 'update', 'delete']; + describe('instance', () => { + const methods = ['getAll', 'get', 'create', 'update', 'delete']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.connections[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(ConnectionsManager).to.throw(ArgumentError, 'Must provide client options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new ConnectionsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = ConnectionsManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new ConnectionsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = ConnectionsManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new ConnectionsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/connections') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/connections').reply(200); }); - it('should accept a callback', function(done) { - this.connections.getAll(function() { + it('should accept a callback', function (done) { + this.connections.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.connections - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.connections.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/connections') - .reply(500); + nock(API_URL).get('/connections').reply(500); - this.connections.getAll().catch(function(err) { + this.connections.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/connections') - .reply(200, data); + const data = [{ test: true }]; + nock(API_URL).get('/connections').reply(200, data); - this.connections.getAll().then(function(connections) { + this.connections.getAll().then((connections) => { expect(connections).to.be.an.instanceOf(Array); expect(connections.length).to.equal(data.length); @@ -97,42 +89,42 @@ describe('ConnectionsManager', function() { }); }); - it('should perform a GET request to /api/v2/connections', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/connections', function (done) { + const { request } = this; - this.connections.getAll().then(function() { + this.connections.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/connections') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.connections.getAll().then(function() { + this.connections.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/connections') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.connections.getAll({ include_fields: true, fields: 'test' }).then(function() { + this.connections.getAll({ include_fields: true, fields: 'test' }).then(() => { expect(request.isDone()).to.be.true; done(); @@ -140,97 +132,88 @@ describe('ConnectionsManager', function() { }); }); - describe('#get', function() { - var params = { id: 5 }; - var data = { + describe('#get', () => { + const params = { id: 5 }; + const data = { id: params.id, - name: 'Test connection' + name: 'Test connection', }; - beforeEach(function() { - this.request = nock(API_URL) - .get('/connections/' + data.id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).get(`/connections/${data.id}`).reply(200); }); - it('should accept a callback', function(done) { - this.connections.get(params, function() { + it('should accept a callback', function (done) { + this.connections.get(params, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.connections - .get(params) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.connections.get(params).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/connections/' + params.id) - .reply(500); + nock(API_URL).get(`/connections/${params.id}`).reply(500); - this.connections.get().catch(function(err) { + this.connections.get().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/connections/' + params.id) - .reply(200, data); + nock(API_URL).get(`/connections/${params.id}`).reply(200, data); - this.connections.get(params).then(function(connection) { + this.connections.get(params).then((connection) => { expect(connection.id).to.equal(data.id); done(); }); }); - it('should perform a GET request to /api/v2/connections/:id', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/connections/:id', function (done) { + const { request } = this; - this.connections.get(params).then(function() { + this.connections.get(params).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/connections') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.connections.getAll().then(function() { + this.connections.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/connections') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.connections.getAll({ include_fields: true, fields: 'test' }).then(function() { + this.connections.getAll({ include_fields: true, fields: 'test' }).then(() => { expect(request.isDone()).to.be.true; done(); @@ -238,78 +221,69 @@ describe('ConnectionsManager', function() { }); }); - describe('#create', function() { - var data = { + describe('#create', () => { + const data = { name: 'Test connection', - options: {} + options: {}, }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/connections') - .reply(200, data); + beforeEach(function () { + this.request = nock(API_URL).post('/connections').reply(200, data); }); - it('should accept a callback', function(done) { - this.connections.create(data, function() { + it('should accept a callback', function (done) { + this.connections.create(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.connections - .create(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.connections.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/connections') - .reply(500); + nock(API_URL).post('/connections').reply(500); - this.connections.create(data).catch(function(err) { + this.connections.create(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/connections', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/connections', function (done) { + const { request } = this; - this.connections.create(data).then(function() { + this.connections.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/connections', data) - .reply(200); + const request = nock(API_URL).post('/connections', data).reply(200); - this.connections.create(data).then(function() { + this.connections.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/connections') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.connections.create(data).then(function() { + this.connections.create(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -317,80 +291,74 @@ describe('ConnectionsManager', function() { }); }); - describe('#update', function() { - var params = { id: 5 }; - var data = { + describe('#update', () => { + const params = { id: 5 }; + const data = { id: 5, name: 'Test connection', - options: {} + options: {}, }; - beforeEach(function() { - this.request = nock(API_URL) - .patch('/connections/' + data.id) - .reply(200, data); + beforeEach(function () { + this.request = nock(API_URL).patch(`/connections/${data.id}`).reply(200, data); }); - it('should accept a callback', function(done) { - this.connections.update(params, data, function() { + it('should accept a callback', function (done) { + this.connections.update(params, data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.connections .update(params, data) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/connections/' + data.id) - .reply(500); + nock(API_URL).patch(`/connections/${data.id}`).reply(500); - this.connections.update(params, data).catch(function(err) { + this.connections.update(params, data).catch((err) => { expect(err).to.exist.to.be.an.instanceOf(Error); done(); }); }); - it('should perform a PATCH request to /api/v2/connections/:id', function(done) { - var request = this.request; + it('should perform a PATCH request to /api/v2/connections/:id', function (done) { + const { request } = this; - this.connections.update(params, data).then(function() { + this.connections.update(params, data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/connections/' + data.id, data) - .reply(200); + const request = nock(API_URL).patch(`/connections/${data.id}`, data).reply(200); - this.connections.update(params, data).then(function() { + this.connections.update(params, data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/connections/' + data.id) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .patch(`/connections/${data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.connections.update(params, data).then(function() { + this.connections.update(params, data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -398,56 +366,166 @@ describe('ConnectionsManager', function() { }); }); - describe('#delete', function() { - var id = 5; + describe('#delete', () => { + const id = 5; + + beforeEach(function () { + this.request = nock(API_URL).delete(`/connections/${id}`).reply(200); + }); + + it('should accept a callback', function (done) { + this.connections.delete({ id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.connections.delete({ id }).then(done.bind(null, null)); + }); + + it(`should perform a DELETE request to /connections/${id}`, function (done) { + const { request } = this; + + this.connections.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete(`/connections/${id}`).reply(500); + + this.connections.delete({ id }).catch((err) => { + expect(err).to.exist; - beforeEach(function() { - this.request = nock(API_URL) - .delete('/connections/' + id) + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/connections/${id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); + + this.connections.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#checkStatus', () => { + const params = { id: 5 }; + const data = { + id: params.id, + name: 'Test connection', + }; + + beforeEach(function () { + this.request = nock(API_URL).get(`/connections/${data.id}/status`).reply(200); }); - it('should accept a callback', function(done) { - this.connections.delete({ id: id }, done.bind(null, null)); + it('should accept a callback', function (done) { + this.connections.checkStatus(params, () => { + done(); + }); }); - it('should return a promise when no callback is given', function(done) { - this.connections.delete({ id: id }).then(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.connections.checkStatus(params).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a DELETE request to /connections/' + id, function(done) { - var request = this.request; + it('should report success', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/connections/${params.id}/status`).reply(200); - this.connections.delete({ id: id }).then(function() { + this.connections.checkStatus(params).then((response) => { + expect(response).to.exist; + done(); + }); + }); + + it('should report failure', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/connections/${params.id}/status`).reply(500); + + this.connections.checkStatus(params).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + }); + + describe('#delete user', () => { + const id = 5; + const email = 'user@domain.com'; + const endpoint = `/connections/${id}/users?email=${encodeURIComponent(email)}`; + + beforeEach(function () { + this.request = nock(API_URL).delete(endpoint, {}).reply(200); + }); + + it('should accept a callback', function (done) { + this.connections.deleteUserByEmail({ id, email }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.connections.deleteUserByEmail({ id, email }).then(done.bind(null, null)); + }); + + it(`should perform a DELETE request to ${endpoint}`, function (done) { + const { request } = this; + + this.connections.deleteUserByEmail({ id, email }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/connections/' + id) - .reply(500); + nock(API_URL).delete(endpoint, {}).reply(500); - this.connections.delete({ id: id }).catch(function(err) { + this.connections.deleteUserByEmail({ id, email }).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should require a connection id', function () { + expect(this.connections.deleteUserByEmail.bind(null, { email })).to.throw( + ArgumentError, + 'The connection id cannot be null or undefined' + ); + }); + + it('should require an email', function () { + expect(this.connections.deleteUserByEmail.bind(null, { id })).to.throw( + ArgumentError, + 'You must provide an email for the deleteUserByEmail method' + ); + }); + + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/connections/' + id) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .delete(endpoint, {}) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.connections.delete({ id: id }).then(function() { + this.connections.deleteUserByEmail({ id, email }).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/management/custom-domains.tests.js b/test/management/custom-domains.tests.js index 1afcc5433..e9b57e80c 100644 --- a/test/management/custom-domains.tests.js +++ b/test/management/custom-domains.tests.js @@ -1,91 +1,83 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var CustomDomainsManager = require(SRC_DIR + '/management/CustomDomainsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const CustomDomainsManager = require(`../../src/management/CustomDomainsManager`); +const { ArgumentError } = require('rest-facade'); -describe('CustomDomainsManager', function() { - before(function() { +describe('CustomDomainsManager', () => { + before(function () { this.token = 'TOKEN'; this.customDomains = new CustomDomainsManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['get', 'getAll', 'create', 'delete', 'verify']; + describe('instance', () => { + const methods = ['get', 'getAll', 'create', 'delete', 'verify']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.customDomains[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(CustomDomainsManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new CustomDomainsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = CustomDomainsManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new CustomDomainsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = CustomDomainsManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new CustomDomainsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/custom-domains') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/custom-domains').reply(200); }); - it('should accept a callback', function(done) { - this.customDomains.getAll(function() { + it('should accept a callback', function (done) { + this.customDomains.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.customDomains - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.customDomains.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/custom-domains') - .reply(500); + nock(API_URL).get('/custom-domains').reply(500); - this.customDomains.getAll().catch(function(err) { + this.customDomains.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = [{ custom_domain_id: 'cd_0000000000000001' }]; - var request = nock(API_URL) - .get('/custom-domains') - .reply(200, data); + const data = [{ custom_domain_id: 'cd_0000000000000001' }]; + nock(API_URL).get('/custom-domains').reply(200, data); - this.customDomains.getAll().then(function(customDomains) { + this.customDomains.getAll().then((customDomains) => { expect(customDomains).to.be.an.instanceOf(Array); expect(customDomains.length).to.equal(data.length); @@ -96,32 +88,32 @@ describe('CustomDomainsManager', function() { }); }); - it('should perform a GET request to /api/v2/custom-domains', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/custom-domains', function (done) { + const { request } = this; - this.customDomains.getAll().then(function() { + this.customDomains.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/custom-domains') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.customDomains.getAll().then(function() { + this.customDomains.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); }); - describe('#get', function() { - beforeEach(function() { + describe('#get', () => { + beforeEach(function () { this.data = [ { custom_domain_id: 'cd_0000000000000001', @@ -131,62 +123,60 @@ describe('CustomDomainsManager', function() { type: 'self_managed_certs', origin_domain_name: 'mycompany_cd_0000000000000001.edge.tenants.auth0.com', verification: { - methods: ['object'] - } - } + methods: ['object'], + }, + }, ]; this.request = nock(API_URL) - .get('/custom-domains/' + this.data[0].custom_domain_id) + .get(`/custom-domains/${this.data[0].custom_domain_id}`) .reply(200, this.data); }); - it('should accept a callback', function(done) { - var params = { id: this.data[0].custom_domain_id }; + it('should accept a callback', function (done) { + const params = { id: this.data[0].custom_domain_id }; this.customDomains.get(params, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.customDomains .get({ id: this.data[0].custom_domain_id }) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/custom-domains/cd_0000000000000001', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/custom-domains/cd_0000000000000001', function (done) { + const { request } = this; - this.customDomains.get({ id: this.data[0].custom_domain_id }).then(function() { + this.customDomains.get({ id: this.data[0].custom_domain_id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/custom-domains/' + this.data.id) - .reply(500); + nock(API_URL).get(`/custom-domains/${this.data.id}`).reply(500); - this.customDomains.get({ id: this.data.id }).catch(function(err) { + this.customDomains.get({ id: this.data.id }).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/custom-domains/' + this.data.id) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .get(`/custom-domains/${this.data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.customDomains.get({ id: this.data.id }).then(function() { + this.customDomains.get({ id: this.data.id }).then(() => { expect(request.isDone()).to.be.true; done(); @@ -194,8 +184,8 @@ describe('CustomDomainsManager', function() { }); }); - describe('#create', function() { - var data = { + describe('#create', () => { + const data = { custom_domain_id: 'cd_0000000000000001', domain: 'login.mycompany.com', primary: false, @@ -203,76 +193,67 @@ describe('CustomDomainsManager', function() { type: 'self_managed_certs', origin_domain_name: 'mycompany_cd_0000000000000001.edge.tenants.auth0.com', verification: { - methods: ['object'] - } + methods: ['object'], + }, }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/custom-domains') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/custom-domains').reply(200); }); - it('should accept a callback', function(done) { - this.customDomains.create(data, function() { + it('should accept a callback', function (done) { + this.customDomains.create(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.customDomains - .create(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.customDomains.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/custom-domains') - .reply(500); + nock(API_URL).post('/custom-domains').reply(500); - this.customDomains.create(data).catch(function(err) { + this.customDomains.create(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/custom-domains', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/custom-domains', function (done) { + const { request } = this; - this.customDomains.create(data).then(function() { + this.customDomains.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/custom-domains', data) - .reply(200); + const request = nock(API_URL).post('/custom-domains', data).reply(200); - this.customDomains.create(data).then(function() { + this.customDomains.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/custom-domains') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.customDomains.create(data).then(function() { + this.customDomains.create(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -280,56 +261,52 @@ describe('CustomDomainsManager', function() { }); }); - describe('#delete', function() { - var id = 'cd_0000000000000001'; + describe('#delete', () => { + const id = 'cd_0000000000000001'; - beforeEach(function() { - this.request = nock(API_URL) - .delete('/custom-domains/' + id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).delete(`/custom-domains/${id}`).reply(200); }); - it('should accept a callback', function(done) { - this.customDomains.delete({ id: id }, done.bind(null, null)); + it('should accept a callback', function (done) { + this.customDomains.delete({ id }, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { - this.customDomains.delete({ id: id }).then(done.bind(null, null)); + it('should return a promise when no callback is given', function (done) { + this.customDomains.delete({ id }).then(done.bind(null, null)); }); - it('should perform a delete request to /custom-domains/' + id, function(done) { - var request = this.request; + it(`should perform a delete request to /custom-domains/${id}`, function (done) { + const { request } = this; - this.customDomains.delete({ id: id }).then(function() { + this.customDomains.delete({ id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/custom-domains/' + id) - .reply(500); + nock(API_URL).delete(`/custom-domains/${id}`).reply(500); - this.customDomains.delete({ id: id }).catch(function(err) { + this.customDomains.delete({ id }).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the authorization header', function(done) { + it('should include the token in the authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/custom-domains/' + id) - .matchHeader('authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .delete(`/custom-domains/${id}`) + .matchHeader('authorization', `Bearer ${this.token}`) .reply(200); - this.customDomains.delete({ id: id }).then(function() { + this.customDomains.delete({ id }).then(() => { expect(request.isDone()).to.be.true; done(); @@ -337,58 +314,54 @@ describe('CustomDomainsManager', function() { }); }); - describe('#verify', function() { - beforeEach(function() { + describe('#verify', () => { + beforeEach(function () { this.data = { id: 'cd_0000000000000001' }; this.request = nock(API_URL) - .post('/custom-domains/' + this.data.id + '/verify') + .post(`/custom-domains/${this.data.id}/verify`) .reply(200, this.data); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.customDomains.verify({ id: this.data.id }, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.customDomains .verify({ id: this.data.id }, {}) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/custom-domains/cd_0000000000000001/verify', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/custom-domains/cd_0000000000000001/verify', function (done) { + const { request } = this; - this.customDomains.verify({ id: this.data.id }).then(function() { + this.customDomains.verify({ id: this.data.id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/custom-domains/' + this.data.id + '/verify') - .reply(200); + const request = nock(API_URL).post(`/custom-domains/${this.data.id}/verify`).reply(200); - this.customDomains.verify({ id: this.data.id }).then(function() { + this.customDomains.verify({ id: this.data.id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/custom-domains/' + this.data.id + '/verify') - .reply(500); + nock(API_URL).post(`/custom-domains/${this.data.id}/verify`).reply(500); - this.customDomains.verify({ id: this.data.id }).catch(function(err) { + this.customDomains.verify({ id: this.data.id }).catch((err) => { expect(err).to.exist; done(); diff --git a/test/management/device-credentials.tests.js b/test/management/device-credentials.tests.js index 5f1c50d07..10cd533f9 100644 --- a/test/management/device-credentials.tests.js +++ b/test/management/device-credentials.tests.js @@ -1,91 +1,83 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var DeviceCredentialsManager = require(SRC_DIR + '/management/DeviceCredentialsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const DeviceCredentialsManager = require(`../../src/management/DeviceCredentialsManager`); +const { ArgumentError } = require('rest-facade'); -describe('DeviceCredentialsManager', function() { - before(function() { +describe('DeviceCredentialsManager', () => { + before(function () { this.token = 'TOKEN'; this.credentials = new DeviceCredentialsManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['createPublicKey', 'getAll', 'delete']; + describe('instance', () => { + const methods = ['createPublicKey', 'getAll', 'delete']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.credentials[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(DeviceCredentialsManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new DeviceCredentialsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = DeviceCredentialsManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new DeviceCredentialsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = DeviceCredentialsManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new DeviceCredentialsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/device-credentials') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/device-credentials').reply(200); }); - it('should accept a callback', function(done) { - this.credentials.getAll(function() { + it('should accept a callback', function (done) { + this.credentials.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.credentials - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.credentials.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/device-credentials') - .reply(500); + nock(API_URL).get('/device-credentials').reply(500); - this.credentials.getAll().catch(function(err) { + this.credentials.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/device-credentials') - .reply(200, data); + const data = [{ test: true }]; + nock(API_URL).get('/device-credentials').reply(200, data); - this.credentials.getAll().then(function(credentials) { + this.credentials.getAll().then((credentials) => { expect(credentials).to.be.an.instanceOf(Array); expect(credentials.length).to.equal(data.length); @@ -96,42 +88,39 @@ describe('DeviceCredentialsManager', function() { }); }); - it('should perform a GET request to /api/v2/device-credentials', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/device-credentials', function (done) { + const { request } = this; - this.credentials.getAll().then(function() { + this.credentials.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/device-credentials') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.credentials.getAll().then(function() { + this.credentials.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var params = { + const params = { include_fields: true, - fields: 'test' + fields: 'test', }; - var request = nock(API_URL) - .get('/device-credentials') - .query(params) - .reply(200); + const request = nock(API_URL).get('/device-credentials').query(params).reply(200); - this.credentials.getAll(params).then(function() { + this.credentials.getAll(params).then(() => { expect(request.isDone()).to.be.true; done(); @@ -139,79 +128,73 @@ describe('DeviceCredentialsManager', function() { }); }); - describe('#createPublicKey', function() { - var data = { + describe('#createPublicKey', () => { + const data = { device_name: 'Sample device', type: 'public_key', - user_id: 'github|1234' + user_id: 'github|1234', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/device-credentials') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/device-credentials').reply(200); }); - it('should accept a callback', function(done) { - this.credentials.createPublicKey(data, function() { + it('should accept a callback', function (done) { + this.credentials.createPublicKey(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.credentials .createPublicKey(data) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/device-credentials') - .reply(500); + nock(API_URL).post('/device-credentials').reply(500); - this.credentials.createPublicKey(data).catch(function(err) { + this.credentials.createPublicKey(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/device-credentials', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/device-credentials', function (done) { + const { request } = this; - this.credentials.createPublicKey(data).then(function() { + this.credentials.createPublicKey(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/device-credentials', data) - .reply(200); + const request = nock(API_URL).post('/device-credentials', data).reply(200); - this.credentials.createPublicKey(data).then(function() { + this.credentials.createPublicKey(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/device-credentials') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.credentials.createPublicKey(data).then(function() { + this.credentials.createPublicKey(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -219,56 +202,52 @@ describe('DeviceCredentialsManager', function() { }); }); - describe('#delete', function() { - var id = 5; + describe('#delete', () => { + const id = 5; - beforeEach(function() { - this.request = nock(API_URL) - .delete('/device-credentials/' + id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).delete(`/device-credentials/${id}`).reply(200); }); - it('should accept a callback', function(done) { - this.credentials.delete({ id: id }, done.bind(null, null)); + it('should accept a callback', function (done) { + this.credentials.delete({ id }, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { - this.credentials.delete({ id: id }).then(done.bind(null, null)); + it('should return a promise when no callback is given', function (done) { + this.credentials.delete({ id }).then(done.bind(null, null)); }); - it('should perform a delete request to /device-credentials/' + id, function(done) { - var request = this.request; + it(`should perform a delete request to /device-credentials/${id}`, function (done) { + const { request } = this; - this.credentials.delete({ id: id }).then(function() { + this.credentials.delete({ id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/device-credentials/' + id) - .reply(500); + nock(API_URL).delete(`/device-credentials/${id}`).reply(500); - this.credentials.delete({ id: id }).catch(function(err) { + this.credentials.delete({ id }).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the authorization header', function(done) { + it('should include the token in the authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/device-credentials/' + id) - .matchHeader('authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .delete(`/device-credentials/${id}`) + .matchHeader('authorization', `Bearer ${this.token}`) .reply(200); - this.credentials.delete({ id: id }).then(function() { + this.credentials.delete({ id }).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/management/email-provider.tests.js b/test/management/email-provider.tests.js index 2d059b639..1cd2c6de1 100644 --- a/test/management/email-provider.tests.js +++ b/test/management/email-provider.tests.js @@ -1,141 +1,130 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var EmailProviderManager = require(SRC_DIR + '/management/EmailProviderManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const EmailProviderManager = require(`../../src/management/EmailProviderManager`); +const { ArgumentError } = require('rest-facade'); -describe('EmailProviderManager', function() { - before(function() { +describe('EmailProviderManager', () => { + before(function () { this.token = 'TOKEN'; this.emailProvider = new EmailProviderManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['configure', 'get', 'update', 'delete']; + describe('instance', () => { + const methods = ['configure', 'get', 'update', 'delete']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.emailProvider[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(EmailProviderManager).to.throw(ArgumentError, 'Must provide client options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new EmailProviderManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = EmailProviderManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new EmailProviderManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = EmailProviderManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new EmailProviderManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#get', function() { - var data = { + describe('#get', () => { + const data = { name: 'Test provider', - options: {} + options: {}, }; - beforeEach(function() { - this.request = nock(API_URL) - .get('/emails/provider') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).get('/emails/provider').reply(200); }); - it('should accept a callback', function(done) { - this.emailProvider.get(function() { + it('should accept a callback', function (done) { + this.emailProvider.get(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.emailProvider - .get() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.emailProvider.get().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/emails/provider') - .reply(500); + nock(API_URL).get('/emails/provider').reply(500); - this.emailProvider.get().catch(function(err) { + this.emailProvider.get().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/emails/provider') - .reply(200, data); + nock(API_URL).get('/emails/provider').reply(200, data); - this.emailProvider.get().then(function(provider) { + this.emailProvider.get().then((provider) => { expect(provider.id).to.equal(data.id); done(); }); }); - it('should perform a GET request to /api/v2/emails/provider', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/emails/provider', function (done) { + const { request } = this; - this.emailProvider.get().then(function() { + this.emailProvider.get().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/emails/provider') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.emailProvider.get().then(function() { + this.emailProvider.get().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var params = { + const params = { include_fields: true, - fields: 'test' + fields: 'test', }; - var request = nock(API_URL) - .get('/emails/provider') - .query(params) - .reply(200); + const request = nock(API_URL).get('/emails/provider').query(params).reply(200); - this.emailProvider.get(params).then(function() { + this.emailProvider.get(params).then(() => { expect(request.isDone()).to.be.true; done(); @@ -143,78 +132,69 @@ describe('EmailProviderManager', function() { }); }); - describe('#configure', function() { - var data = { + describe('#configure', () => { + const data = { name: 'Test provider', - credentials: {} + credentials: {}, }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/emails/provider') - .reply(200, data); + beforeEach(function () { + this.request = nock(API_URL).post('/emails/provider').reply(200, data); }); - it('should accept a callback', function(done) { - this.emailProvider.configure(data, function() { + it('should accept a callback', function (done) { + this.emailProvider.configure(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.emailProvider - .configure(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.emailProvider.configure(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/emails/provider') - .reply(500); + nock(API_URL).post('/emails/provider').reply(500); - this.emailProvider.configure(data).catch(function(err) { + this.emailProvider.configure(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/emails/provider', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/emails/provider', function (done) { + const { request } = this; - this.emailProvider.configure(data).then(function() { + this.emailProvider.configure(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/emails/provider', data) - .reply(200); + const request = nock(API_URL).post('/emails/provider', data).reply(200); - this.emailProvider.configure(data).then(function() { + this.emailProvider.configure(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/emails/provider') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.emailProvider.configure(data).then(function() { + this.emailProvider.configure(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -222,78 +202,69 @@ describe('EmailProviderManager', function() { }); }); - describe('#update', function() { - var data = { + describe('#update', () => { + const data = { name: 'Test provider', - credentials: {} + credentials: {}, }; - beforeEach(function() { - this.request = nock(API_URL) - .patch('/emails/provider') - .reply(200, data); + beforeEach(function () { + this.request = nock(API_URL).patch('/emails/provider').reply(200, data); }); - it('should accept a callback', function(done) { - this.emailProvider.update({}, data, function() { + it('should accept a callback', function (done) { + this.emailProvider.update({}, data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.emailProvider - .update({}, data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.emailProvider.update({}, data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/emails/provider/' + data.id) - .reply(500); + nock(API_URL).patch(`/emails/provider/${data.id}`).reply(500); - this.emailProvider.update({}, data).catch(function(err) { + this.emailProvider.update({}, data).catch((err) => { expect(err).to.exist.to.be.an.instanceOf(Error); done(); }); }); - it('should perform a PATCH request to /api/v2/emails/provider', function(done) { - var request = this.request; + it('should perform a PATCH request to /api/v2/emails/provider', function (done) { + const { request } = this; - this.emailProvider.update({}, data).then(function() { + this.emailProvider.update({}, data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/emails/provider', data) - .reply(200); + const request = nock(API_URL).patch('/emails/provider', data).reply(200); - this.emailProvider.update({}, data).then(function() { + this.emailProvider.update({}, data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .patch('/emails/provider') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.emailProvider.update({}, data).then(function() { + this.emailProvider.update({}, data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -301,54 +272,50 @@ describe('EmailProviderManager', function() { }); }); - describe('#delete', function() { - beforeEach(function() { - this.request = nock(API_URL) - .delete('/emails/provider') - .reply(200); + describe('#delete', () => { + beforeEach(function () { + this.request = nock(API_URL).delete('/emails/provider').reply(200); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.emailProvider.delete({}, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { + it('should return a promise when no callback is given', function (done) { this.emailProvider.delete().then(done.bind(null, null)); }); - it('should perform a DELETE request to /emails/provider', function(done) { - var request = this.request; + it('should perform a DELETE request to /emails/provider', function (done) { + const { request } = this; - this.emailProvider.delete().then(function() { + this.emailProvider.delete().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/emails/provider') - .reply(500); + nock(API_URL).delete('/emails/provider').reply(500); - this.emailProvider.delete().catch(function(err) { + this.emailProvider.delete().catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .delete('/emails/provider') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.emailProvider.delete().then(function() { + this.emailProvider.delete().then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/management/email-templates.tests.js b/test/management/email-templates.tests.js index 24139e5f9..388f5c4b6 100644 --- a/test/management/email-templates.tests.js +++ b/test/management/email-templates.tests.js @@ -1,9 +1,9 @@ -var expect = require('chai').expect; -var nock = require('nock'); -var EmailTemplatesManager = require('../../src/management/EmailTemplatesManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const { expect } = require('chai'); +const nock = require('nock'); +const EmailTemplatesManager = require('../../src/management/EmailTemplatesManager'); +const { ArgumentError } = require('rest-facade'); -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; const TEMPLATE_NAME = 'foobar'; const DEFAULT_PARAMS = { name: TEMPLATE_NAME }; const DEFAULT_DATA = { @@ -14,95 +14,95 @@ const DEFAULT_DATA = { subject: '', syntax: 'liquid', urlLifetimeInSeconds: 0, - enabled: false + enabled: false, }; -describe('EmailTemplatesManager', function() { - before(function() { +describe('EmailTemplatesManager', () => { + before(function () { this.token = 'TOKEN'; this.emailTemplates = new EmailTemplatesManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['get', 'create', 'update']; + describe('instance', () => { + const methods = ['get', 'create', 'update']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.emailTemplates[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(EmailTemplatesManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new EmailTemplatesManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = EmailTemplatesManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a valid string as base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new EmailTemplatesManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = EmailTemplatesManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'Must provide a valid string as base URL for the API'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new EmailTemplatesManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#get', function() { - beforeEach(function() { + describe('#get', () => { + beforeEach(function () { this.request = nock(API_URL) - .get('/email-templates/' + TEMPLATE_NAME) + .get(`/email-templates/${TEMPLATE_NAME}`) .reply(200, DEFAULT_DATA); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.emailTemplates.get(DEFAULT_PARAMS, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.emailTemplates .get(DEFAULT_PARAMS) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a GET request to /api/v2/email-templates/' + TEMPLATE_NAME, function(done) { - var request = this.request; - this.emailTemplates.get(DEFAULT_PARAMS).then(function() { + it(`should perform a GET request to /api/v2/email-templates/${TEMPLATE_NAME}`, function (done) { + const { request } = this; + this.emailTemplates.get(DEFAULT_PARAMS).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/email-templates/' + TEMPLATE_NAME) - .reply(500); + nock(API_URL).get(`/email-templates/${TEMPLATE_NAME}`).reply(500); - this.emailTemplates.get(DEFAULT_PARAMS).catch(function(err) { + this.emailTemplates.get(DEFAULT_PARAMS).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/email-templates/' + TEMPLATE_NAME) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .get(`/email-templates/${TEMPLATE_NAME}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.emailTemplates.get(DEFAULT_PARAMS).then(function() { + this.emailTemplates.get(DEFAULT_PARAMS).then(() => { expect(request.isDone()).to.be.true; done(); @@ -110,73 +110,67 @@ describe('EmailTemplatesManager', function() { }); }); - describe('#create', function() { - beforeEach(function() { - this.request = nock(API_URL) - .post('/email-templates') - .reply(200); + describe('#create', () => { + beforeEach(function () { + this.request = nock(API_URL).post('/email-templates').reply(200); }); - it('should accept a callback', function(done) { - this.emailTemplates.create(DEFAULT_DATA, function() { + it('should accept a callback', function (done) { + this.emailTemplates.create(DEFAULT_DATA, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.emailTemplates .create(DEFAULT_DATA) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/email-templates') - .reply(500); + nock(API_URL).post('/email-templates').reply(500); - this.emailTemplates.create(DEFAULT_DATA).catch(function(err) { + this.emailTemplates.create(DEFAULT_DATA).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/email-templates', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/email-templates', function (done) { + const { request } = this; - this.emailTemplates.create(DEFAULT_DATA).then(function() { + this.emailTemplates.create(DEFAULT_DATA).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/email-templates', DEFAULT_DATA) - .reply(200); + const request = nock(API_URL).post('/email-templates', DEFAULT_DATA).reply(200); - this.emailTemplates.create(DEFAULT_DATA).then(function() { + this.emailTemplates.create(DEFAULT_DATA).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/email-templates') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.emailTemplates.create(DEFAULT_DATA).then(function() { + this.emailTemplates.create(DEFAULT_DATA).then(() => { expect(request.isDone()).to.be.true; done(); @@ -184,60 +178,56 @@ describe('EmailTemplatesManager', function() { }); }); - describe('#update', function() { - beforeEach(function() { + describe('#update', () => { + beforeEach(function () { this.patchData = { from: 'new@email.com' }; this.request = nock(API_URL) - .patch('/email-templates/' + TEMPLATE_NAME) + .patch(`/email-templates/${TEMPLATE_NAME}`) .reply(200, DEFAULT_DATA); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.emailTemplates.update(DEFAULT_PARAMS, {}, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.emailTemplates .update(DEFAULT_PARAMS, {}) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a PATCH request to /api/v2/email-templates/' + TEMPLATE_NAME, function( - done - ) { - var request = this.request; + it(`should perform a PATCH request to /api/v2/email-templates/${TEMPLATE_NAME}`, function (done) { + const { request } = this; - this.emailTemplates.update(DEFAULT_PARAMS, {}).then(function() { + this.emailTemplates.update(DEFAULT_PARAMS, {}).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/email-templates/' + TEMPLATE_NAME, this.patchData) + const request = nock(API_URL) + .patch(`/email-templates/${TEMPLATE_NAME}`, this.patchData) .reply(200); - this.emailTemplates.update(DEFAULT_PARAMS, this.patchData).then(function() { + this.emailTemplates.update(DEFAULT_PARAMS, this.patchData).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/email-templates/' + TEMPLATE_NAME) - .reply(500); + nock(API_URL).patch(`/email-templates/${TEMPLATE_NAME}`).reply(500); - this.emailTemplates.update(DEFAULT_PARAMS, this.patchData).catch(function(err) { + this.emailTemplates.update(DEFAULT_PARAMS, this.patchData).catch((err) => { expect(err).to.exist; done(); diff --git a/test/management/grants.tests.js b/test/management/grants.tests.js new file mode 100644 index 000000000..d880effb1 --- /dev/null +++ b/test/management/grants.tests.js @@ -0,0 +1,163 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenant.auth0.com'; + +const GrantsManager = require(`../../src/management/GrantsManager`); +const { ArgumentError } = require('rest-facade'); + +describe('GrantsManager', () => { + before(function () { + this.token = 'TOKEN'; + this.grants = new GrantsManager({ + headers: { + authorization: `Bearer ${this.token}`, + }, + baseUrl: API_URL, + }); + }); + + afterEach(() => { + nock.cleanAll(); + }); + + describe('instance', () => { + const methods = ['getAll', 'delete']; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.grants[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new GrantsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new GrantsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new GrantsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/grants').reply(200); + }); + + it('should accept a callback', function (done) { + this.grants.getAll(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.grants.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/grants').reply(500); + + this.grants.getAll().catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const data = [{ test: true }]; + nock(API_URL).get('/grants').reply(200, data); + + this.grants.getAll().then((grants) => { + expect(grants).to.be.an.instanceOf(Array); + + expect(grants.length).to.equal(data.length); + + expect(grants[0].test).to.equal(data[0].test); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/grants', function (done) { + const { request } = this; + + this.grants.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/grants') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.grants.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/grants') + .query({ + include_fields: true, + fields: 'test', + }) + .reply(200); + + this.grants.getAll({ include_fields: true, fields: 'test' }).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + }); + + describe('#delete', () => { + const id = 5; + + beforeEach(function () { + this.request = nock(API_URL).delete(`/grants/${id}`).reply(200); + }); + + it('should accept a callback', function (done) { + this.grants.delete({ id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.grants.delete({ id }).then(done.bind(null, null)); + }); + + it(`should perform a DELETE request to /grants/${id}`, function (done) { + const { request } = this; + + this.grants.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); +}); diff --git a/test/management/guardian.tests.js b/test/management/guardian.tests.js index b3fd95731..74ebf3200 100644 --- a/test/management/guardian.tests.js +++ b/test/management/guardian.tests.js @@ -1,194 +1,190 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenants.auth0.com'; +const API_URL = 'https://tenants.auth0.com'; -var GuardianManager = require(SRC_DIR + '/management/GuardianManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const GuardianManager = require(`../../src/management/GuardianManager`); +const { ArgumentError } = require('rest-facade'); -describe('GuardianManager', function() { - before(function() { +describe('GuardianManager', () => { + before(function () { this.token = 'TOKEN'; this.guardian = new GuardianManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = [ + describe('instance', () => { + const methods = [ 'getGuardianEnrollment', 'deleteGuardianEnrollment', 'getFactors', + 'getFactorSettings', 'getFactorProvider', 'updateFactorProvider', 'getFactorTemplates', 'updateFactorTemplates', - 'updateFactor' + 'updateFactor', + 'updateFactorSettings', + 'getPhoneFactorSelectedProvider', + 'updatePhoneFactorSelectedProvider', + 'getPhoneFactorMessageTypes', + 'updatePhoneFactorMessageTypes', ]; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.guardian[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(GuardianManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new GuardianManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var manager = GuardianManager.bind(null, {}); - - expect(manager).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new GuardianManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var manager = GuardianManager.bind(null, { baseUrl: '' }); - - expect(manager).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new GuardianManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getGuardianEnrollment', function() { - beforeEach(function() { + describe('#getGuardianEnrollment', () => { + beforeEach(function () { this.data = { - id: 'dev_0000000000000001' + id: 'dev_0000000000000001', }; this.params = { id: this.data.id }; - this.request = nock(API_URL) - .get('/guardian/enrollments/' + this.data.id) - .reply(200); + this.request = nock(API_URL).get(`/guardian/enrollments/${this.data.id}`).reply(200); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.guardian.getGuardianEnrollment(this.params, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.guardian .getGuardianEnrollment(this.params) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/guardian/enrollment') - .reply(500); + nock(API_URL).get('/guardian/enrollment').reply(500); - this.guardian.getGuardianEnrollment(this.params).catch(function(err) { + this.guardian.getGuardianEnrollment(this.params).catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = { + const data = { id: 'dev_0000000000000001', status: 'pending', name: 'iPhone 7', identifier: '76dc-a90c-a88c-a90c-a88c-a88c-a90c', phone_number: '+1 999999999999', enrolled_at: '2016-07-12T17:56:26.804Z', - last_auth: '2016-07-12T17:56:26.804Z' + last_auth: '2016-07-12T17:56:26.804Z', }; - var request = nock(API_URL) - .get('/guardian/enrollments/' + data.id) - .reply(200, data); + nock(API_URL).get(`/guardian/enrollments/${data.id}`).reply(200, data); - this.guardian.getGuardianEnrollment(this.params).then(function(enrollment) { + this.guardian.getGuardianEnrollment(this.params).then((enrollment) => { expect(enrollment).to.deep.equal(data); done(); }); }); - it('should perform a GET request to /api/v2/guardian/enrollments', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/guardian/enrollments', function (done) { + const { request } = this; - var params = { id: this.data.id }; - this.guardian.getGuardianEnrollment(this.params).then(function() { + this.guardian.getGuardianEnrollment(this.params).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/guardian/enrollments/' + this.data.id) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .get(`/guardian/enrollments/${this.data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.getGuardianEnrollment(this.params).then(function() { + this.guardian.getGuardianEnrollment(this.params).then(() => { expect(request.isDone()).to.be.true; done(); }); }); }); - describe('#deleteGuardianEnrollment', function() { - beforeEach(function() { + describe('#deleteGuardianEnrollment', () => { + beforeEach(function () { this.data = { - id: 'dev_0000000000000001' + id: 'dev_0000000000000001', }; - this.request = nock(API_URL) - .delete('/guardian/enrollments/' + this.data.id) - .reply(200); + this.request = nock(API_URL).delete(`/guardian/enrollments/${this.data.id}`).reply(200); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.guardian.deleteGuardianEnrollment(this.data, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { + it('should return a promise when no callback is given', function (done) { this.guardian.deleteGuardianEnrollment(this.data).then(done.bind(null, null)); }); - it('should perform a DELETE request to /guardian/enrollments/:id', function(done) { - var request = this.request; + it('should perform a DELETE request to /guardian/enrollments/:id', function (done) { + const { request } = this; - this.guardian.deleteGuardianEnrollment(this.data).then(function() { + this.guardian.deleteGuardianEnrollment(this.data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/guardian/enrollments/' + this.data.id) - .reply(500); + nock(API_URL).delete(`/guardian/enrollments/${this.data.id}`).reply(500); - this.guardian.deleteGuardianEnrollment(this.data).catch(function(err) { + this.guardian.deleteGuardianEnrollment(this.data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the authorization header', function(done) { + it('should include the token in the authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/guardian/enrollments/' + this.data.id) - .matchHeader('authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .delete(`/guardian/enrollments/${this.data.id}`) + .matchHeader('authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.deleteGuardianEnrollment(this.data).then(function() { + this.guardian.deleteGuardianEnrollment(this.data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -196,79 +192,73 @@ describe('GuardianManager', function() { }); }); - describe('#createEnrollmentTicket', function() { - var data = { + describe('#createEnrollmentTicket', () => { + const data = { user_id: '', email: '', - send_mail: false + send_mail: false, }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/guardian/enrollments/ticket') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/guardian/enrollments/ticket').reply(200); }); - it('should accept a callback', function(done) { - this.guardian.createEnrollmentTicket(data, function() { + it('should accept a callback', function (done) { + this.guardian.createEnrollmentTicket(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.guardian .createEnrollmentTicket(data) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/guardian/enrollments/ticket') - .reply(500); + nock(API_URL).post('/guardian/enrollments/ticket').reply(500); - this.guardian.createEnrollmentTicket(data).catch(function(err) { + this.guardian.createEnrollmentTicket(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/guardian/enrollments/ticket', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/guardian/enrollments/ticket', function (done) { + const { request } = this; - this.guardian.createEnrollmentTicket(data).then(function() { + this.guardian.createEnrollmentTicket(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/guardian/enrollments/ticket', data) - .reply(200); + const request = nock(API_URL).post('/guardian/enrollments/ticket', data).reply(200); - this.guardian.createEnrollmentTicket(data).then(function() { + this.guardian.createEnrollmentTicket(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/guardian/enrollments/ticket') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.createEnrollmentTicket(data).then(function() { + this.guardian.createEnrollmentTicket(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -276,65 +266,119 @@ describe('GuardianManager', function() { }); }); - describe('#getFactors', function() { - beforeEach(function() { + describe('#getFactors', () => { + beforeEach(function () { this.data = [ { name: 'sms', enabled: true, trial_expired: false }, { name: 'push-notification', enabled: false, trial_expired: false }, { name: 'otp', enabled: false, trial_expired: false }, { name: 'email', enabled: false, trial_expired: false }, - { name: 'duo', enabled: false, trial_expired: false } + { name: 'duo', enabled: false, trial_expired: false }, ]; - this.request = nock(API_URL) + this.request = nock(API_URL).get('/guardian/factors').reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.guardian.getFactors(done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.guardian.getFactors().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/guardian/factors', function (done) { + const { request } = this; + + this.guardian.getFactors().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/guardian/factors').reply(500); + + this.guardian.getFactors().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) .get('/guardian/factors') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.guardian.getFactors().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getFactorSettings', () => { + beforeEach(function () { + this.params = { name: 'webauthn-roaming' }; + this.data = { + userVerification: 'discouraged', + overrideRelyingParty: false, + }; + this.request = nock(API_URL) + .get(`/guardian/factors/${this.params.name}/settings`) .reply(200, this.data); }); - it('should accept a callback', function(done) { - this.guardian.getFactors(done.bind(null, null)); + it('should accept a callback', function (done) { + this.guardian.getFactorSettings(this.params, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.guardian - .getFactors() + .getFactorSettings(this.params) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/guardian/factors', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/guardian/factors/webauthn-roaming/settings', function (done) { + const { request } = this; - this.guardian.getFactors().then(function() { + this.guardian.getFactorSettings(this.params).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/guardian/factors') - .reply(500); + nock(API_URL).get(`/guardian/factors/${this.params.name}/settings`).reply(500); - this.guardian.getFactors().catch(function(err) { + this.guardian.getFactorSettings(this.params).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/guardian/factors') - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .get(`/guardian/factors/${this.params.name}/settings`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.getFactors().then(function() { + this.guardian.getFactorSettings(this.params).then(() => { expect(request.isDone()).to.be.true; done(); @@ -342,65 +386,65 @@ describe('GuardianManager', function() { }); }); - describe('#getFactorProvider', function() { - beforeEach(function() { + describe('#getFactorProvider', () => { + beforeEach(function () { this.params = { name: 'sms', provider: 'twilio' }; this.data = { from: '+1223323', messaging_service_sid: '5dEkAiHLPCuQ1uJj4qNXcAnERFAL6cpq', auth_token: 'zw5Ku6z2sxhd0ZVXto5SDHX6KPDByJPU', - sid: 'wywA2BH4VqTpfywiDuyDAYZL3xQjoO40' + sid: 'wywA2BH4VqTpfywiDuyDAYZL3xQjoO40', }; this.request = nock(API_URL) - .get('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider) + .get(`/guardian/factors/${this.params.name}/providers/${this.params.provider}`) .reply(200, this.data); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.guardian.getFactorProvider(this.params, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.guardian .getFactorProvider(this.params) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/guardian/factors/sms/twilio', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/guardian/factors/sms/twilio', function (done) { + const { request } = this; - this.guardian.getFactorProvider(this.params).then(function() { + this.guardian.getFactorProvider(this.params).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('guardian/factors/' + this.params.name + '/providers/' + this.params.provider) + nock(API_URL) + .get(`/guardian/factors/${this.params.name}/providers/${this.params.provider}`) .reply(500); - this.guardian.getFactorProvider(this.params).catch(function(err) { + this.guardian.getFactorProvider(this.params).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .get(`/guardian/factors/${this.params.name}/providers/${this.params.provider}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.getFactorProvider(this.params).then(function() { + this.guardian.getFactorProvider(this.params).then(() => { expect(request.isDone()).to.be.true; done(); @@ -408,77 +452,77 @@ describe('GuardianManager', function() { }); }); - describe('#updateFactorProvider', function() { - beforeEach(function() { + describe('#updateFactorProvider', () => { + beforeEach(function () { this.params = { name: 'sms', provider: 'twilio' }; this.data = { from: '+1223323', messaging_service_sid: '5dEkAiHLPCuQ1uJj4qNXcAnERFAL6cpq', auth_token: 'zw5Ku6z2sxhd0ZVXto5SDHX6KPDByJPU', - sid: 'wywA2BH4VqTpfywiDuyDAYZL3xQjoO40' + sid: 'wywA2BH4VqTpfywiDuyDAYZL3xQjoO40', }; }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.guardian.updateFactorProvider({ id: 5 }, {}, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.guardian .updateFactorProvider(this.params, {}) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a PUT request to /api/v2/guardian/factors/sms/providers/twilio', function(done) { - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider) + it('should perform a PUT request to /api/v2/guardian/factors/sms/providers/twilio', function (done) { + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/providers/${this.params.provider}`) .reply(200, this.data); - this.guardian.updateFactorProvider(this.params, this.data).then(function() { + this.guardian.updateFactorProvider(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider) + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/providers/${this.params.provider}`, this.data) .reply(200); - this.guardian.updateFactorProvider(this.params, this.data).then(function() { + this.guardian.updateFactorProvider(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider) + nock(API_URL) + .put(`/guardian/factors/${this.params.name}/providers/${this.params.provider}`) .reply(500); - this.guardian.updateFactorProvider(this.params, this.data).catch(function(err) { + this.guardian.updateFactorProvider(this.params, this.data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/providers/${this.params.provider}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.updateFactorProvider(this.params, this.data).then(function() { + this.guardian.updateFactorProvider(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -486,65 +530,61 @@ describe('GuardianManager', function() { }); }); - describe('#getFactorTemplates', function() { - beforeEach(function() { + describe('#getFactorTemplates', () => { + beforeEach(function () { this.params = { name: 'sms' }; this.data = { enrollment_message: '{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.', - verification_message: '{{code}} is your verification code for {{tenant.friendly_name}}' + verification_message: '{{code}} is your verification code for {{tenant.friendly_name}}', }; - this.request = nock(API_URL) - .get('/guardian/factors/sms/templates') - .reply(200, this.data); + this.request = nock(API_URL).get('/guardian/factors/sms/templates').reply(200, this.data); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.guardian.getFactorTemplates(this.params, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.guardian .getFactorTemplates(this.params) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/guardian/factors/sms/templates', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/guardian/factors/sms/templates', function (done) { + const { request } = this; - this.guardian.getFactorTemplates(this.params).then(function() { + this.guardian.getFactorTemplates(this.params).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/guardian/factors/sms/templates') - .reply(500); + nock(API_URL).get('/guardian/factors/sms/templates').reply(500); - this.guardian.getFactorTemplates(this.params).catch(function(err) { + this.guardian.getFactorTemplates(this.params).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/guardian/factors/sms/templates') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.getFactorTemplates(this.params).then(function() { + this.guardian.getFactorTemplates(this.params).then(() => { expect(request.isDone()).to.be.true; done(); @@ -552,76 +592,74 @@ describe('GuardianManager', function() { }); }); - describe('#updateFactorTemplates', function() { - beforeEach(function() { + describe('#updateFactorTemplates', () => { + beforeEach(function () { this.params = { name: 'sms' }; this.data = { enrollment_message: '{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.', - verification_message: '{{code}} is your verification code for {{tenant.friendly_name}}' + verification_message: '{{code}} is your verification code for {{tenant.friendly_name}}', }; }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.guardian.updateFactorTemplates(this.params, {}, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.guardian .updateFactorTemplates(this.params, this.data) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a PUT request to /api/v2/guardian/factors/sms/templates', function(done) { - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name + '/templates') + it('should perform a PUT request to /api/v2/guardian/factors/sms/templates', function (done) { + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/templates`) .reply(200, this.data); - this.guardian.updateFactorTemplates(this.params, this.data).then(function() { + this.guardian.updateFactorTemplates(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name + '/templates') + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/templates`, this.data) .reply(200); - this.guardian.updateFactorTemplates(this.params, this.data).then(function() { + this.guardian.updateFactorTemplates(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name + '/templates') - .reply(500); + nock(API_URL).put(`/guardian/factors/${this.params.name}/templates`).reply(500); - this.guardian.updateFactorTemplates(this.params, this.data).catch(function(err) { + this.guardian.updateFactorTemplates(this.params, this.data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name + '/templates') - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/templates`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.updateFactorTemplates(this.params, this.data).then(function() { + this.guardian.updateFactorTemplates(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -629,74 +667,536 @@ describe('GuardianManager', function() { }); }); - describe('#updateFactor', function() { - beforeEach(function() { + describe('#updateFactor', () => { + beforeEach(function () { this.params = { name: 'sms' }; this.data = { - enabled: true + enabled: true, }; }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.guardian.updateFactor(this.params, {}, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.guardian .updateFactor(this.params, this.data) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should perform a PUT request to /api/v2/guardian/factors/sms', function(done) { - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name) + it('should perform a PUT request to /api/v2/guardian/factors/sms', function (done) { + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}`) .reply(200, this.data); - this.guardian.updateFactor(this.params, this.data).then(function() { + this.guardian.updateFactor(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name) + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}`, this.data) .reply(200); - this.guardian.updateFactor(this.params, this.data).then(function() { + this.guardian.updateFactor(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name) - .reply(500); + nock(API_URL).put(`/guardian/factors/${this.params.name}`).reply(500); + + this.guardian.updateFactor(this.params, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.guardian.updateFactor(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateFactorSettings', () => { + beforeEach(function () { + this.params = { name: 'webauthn-roaming' }; + this.data = { + userVerification: 'discouraged', + overrideRelyingParty: false, + }; + }); + + it('should accept a callback', function (done) { + this.guardian.updateFactorSettings({ id: 5 }, {}, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.guardian + .updateFactorSettings(this.params, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PUT request to /api/v2/guardian/factors/webauthn-roaming/settings', function (done) { + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/settings`) + .reply(200, this.data); + + this.guardian.updateFactorSettings(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/settings`, this.data) + .reply(200); + + this.guardian.updateFactorSettings(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).put(`/guardian/factors/${this.params.name}/settings`).reply(500); + + this.guardian.updateFactorSettings(this.params, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put(`/guardian/factors/${this.params.name}/settings`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.guardian.updateFactorSettings(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getPolicies', () => { + beforeEach(function () { + this.data = ['all-applications']; + + this.request = nock(API_URL).get('/guardian/policies').reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.guardian.getPolicies(done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.guardian.getPolicies().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/guardian/policies', function (done) { + const { request } = this; + + this.guardian.getPolicies().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/guardian/policies').reply(500); + + this.guardian.getPolicies().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/guardian/policies') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.guardian.getPolicies().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updatePolicies', () => { + beforeEach(function () { + this.params = {}; + this.data = ['all-applications']; + }); + + it('should accept a callback', function (done) { + this.guardian.updatePolicies(this.params, this.data, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.guardian + .updatePolicies(this.params, this.data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PUT request to /api/v2/guardian/policies', function (done) { + const request = nock(API_URL).put('/guardian/policies').reply(200, this.data); + + this.guardian.updatePolicies(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).put('/guardian/policies', this.data).reply(200); + + this.guardian.updatePolicies(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).put('/guardian/policies').reply(500); + + this.guardian.updatePolicies(this.params, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put('/guardian/policies') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.guardian.updatePolicies(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getPhoneFactorSelectedProvider', () => { + beforeEach(function () { + this.data = { + provider: 'twilio', + }; + + this.request = nock(API_URL) + .get('/guardian/factors/sms/selected-provider') + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.guardian.getPhoneFactorSelectedProvider(done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.guardian + .getPhoneFactorSelectedProvider() + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/guardian/factors/sms/selected-provider', function (done) { + const { request } = this; + + this.guardian.getPhoneFactorSelectedProvider().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/guardian/factors/sms/selected-provider').reply(500); + + this.guardian.getPhoneFactorSelectedProvider().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/guardian/factors/sms/selected-provider') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.guardian.getPhoneFactorSelectedProvider().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updatePhoneFactorSelectedProvider', () => { + beforeEach(function () { + this.params = {}; + this.data = { + provider: 'twilio', + }; + }); + + it('should accept a callback', function (done) { + this.guardian.updatePhoneFactorSelectedProvider( + this.params, + this.data, + done.bind(null, null) + ); + }); + + it('should return a promise if no callback is given', function (done) { + this.guardian + .updatePhoneFactorSelectedProvider(this.params, this.data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PUT request to /api/v2/guardian/factors/sms/selected-provider', function (done) { + const request = nock(API_URL) + .put('/guardian/factors/sms/selected-provider') + .reply(200, this.data); + + this.guardian.updatePhoneFactorSelectedProvider(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put('/guardian/factors/sms/selected-provider', this.data) + .reply(200); + + this.guardian.updatePhoneFactorSelectedProvider(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).put('/guardian/factors/sms/selected-provider').reply(500); + + this.guardian.updatePhoneFactorSelectedProvider(this.params, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put('/guardian/factors/sms/selected-provider') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.guardian.updatePhoneFactorSelectedProvider(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getPhoneFactorMessageTypes', () => { + beforeEach(function () { + this.data = { + message_types: ['sms', 'voice'], + }; + + this.request = nock(API_URL) + .get('/guardian/factors/phone/message-types') + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.guardian.getPhoneFactorMessageTypes(done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.guardian + .getPhoneFactorMessageTypes() + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/guardian/factors/phone/message-types', function (done) { + const { request } = this; + + this.guardian.getPhoneFactorMessageTypes().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/guardian/factors/phone/message-types').reply(500); + + this.guardian.getPhoneFactorMessageTypes().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/guardian/factors/phone/message-types') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.guardian.getPhoneFactorMessageTypes().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updatePhoneFactorMessageTypes', () => { + beforeEach(function () { + this.params = {}; + this.data = { + message_types: ['sms', 'voice'], + }; + }); + + it('should accept a callback', function (done) { + this.guardian.updatePhoneFactorMessageTypes(this.params, this.data, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.guardian + .updatePhoneFactorMessageTypes(this.params, this.data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PUT request to /api/v2/guardian/factors/phone/message-types', function (done) { + const request = nock(API_URL) + .put('/guardian/factors/phone/message-types') + .reply(200, this.data); + + this.guardian.updatePhoneFactorMessageTypes(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put('/guardian/factors/phone/message-types', this.data) + .reply(200); + + this.guardian.updatePhoneFactorMessageTypes(this.params, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).put('/guardian/factors/phone/message-types').reply(500); - this.guardian.updateFactor(this.params, this.data).catch(function(err) { + this.guardian.updatePhoneFactorMessageTypes(this.params, this.data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/guardian/factors/' + this.params.name) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .put('/guardian/factors/phone/message-types') + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.guardian.updateFactor(this.params, this.data).then(function() { + this.guardian.updatePhoneFactorMessageTypes(this.params, this.data).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/management/hooks.tests.js b/test/management/hooks.tests.js new file mode 100644 index 000000000..fca141c39 --- /dev/null +++ b/test/management/hooks.tests.js @@ -0,0 +1,660 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenant.auth0.com'; + +const HookManager = require(`../../src/management/HooksManager`); +const { ArgumentError } = require('rest-facade'); + +describe('HookManager', () => { + before(function () { + this.token = 'TOKEN'; + this.hooks = new HookManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = [ + 'get', + 'getAll', + 'create', + 'update', + 'delete', + 'getSecrets', + 'addSecrets', + 'updateSecrets', + 'removeSecrets', + ]; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.hooks[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new HookManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new HookManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new HookManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/hooks').reply(200); + }); + + it('should accept a callback', function (done) { + this.hooks.getAll(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.hooks.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/hooks').reply(500); + + this.hooks.getAll().catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const data = [{ test: true }]; + nock(API_URL).get('/hooks').reply(200, data); + + this.hooks.getAll().then((credentials) => { + expect(credentials).to.be.an.instanceOf(Array); + + expect(credentials.length).to.equal(data.length); + + expect(credentials[0].test).to.equal(data[0].test); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/hooks', function (done) { + const { request } = this; + + this.hooks.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/hooks') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.hooks.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const params = { + include_fields: true, + fields: 'test', + }; + const request = nock(API_URL).get('/hooks').query(params).reply(200); + + this.hooks.getAll(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#get', () => { + beforeEach(function () { + this.data = { + id: 5, + name: 'Test hook', + enabled: true, + script: "function (user, contest, callback) { console.log('Test'); }", + stage: 'login_success', + }; + + this.request = nock(API_URL).get(`/hooks/${this.data.id}`).reply(200, this.data); + }); + + it('should accept a callback', function (done) { + const params = { id: this.data.id }; + + this.hooks.get(params, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.hooks.get({ id: this.data.id }).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should perform a POST request to /api/v2/hooks/5', function (done) { + const { request } = this; + + this.hooks.get({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/hooks/${this.data.id}`).reply(500); + + this.hooks.get({ id: this.data.id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/hooks/${this.data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.hooks.get({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#create', () => { + const data = { + id: 5, + name: 'Test hook', + enabled: true, + script: "function (user, contest, callback) { console.log('Test'); }", + stage: 'login_success', + }; + + beforeEach(function () { + this.request = nock(API_URL).post('/hooks').reply(200); + }); + + it('should accept a callback', function (done) { + this.hooks.create(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.hooks.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post('/hooks').reply(500); + + this.hooks.create(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/hooks', function (done) { + const { request } = this; + + this.hooks.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).post('/hooks', data).reply(200); + + this.hooks.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post('/hooks') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.hooks.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#update', () => { + beforeEach(function () { + this.data = { id: 5 }; + + this.request = nock(API_URL).patch(`/hooks/${this.data.id}`).reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.hooks.update({ id: 5 }, {}, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.hooks.update({ id: 5 }, {}).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should perform a PATCH request to /api/v2/hooks/5', function (done) { + const { request } = this; + + this.hooks.update({ id: 5 }, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).patch(`/hooks/${this.data.id}`, this.data).reply(200); + + this.hooks.update({ id: 5 }, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/hooks/${this.data.id}`).reply(500); + + this.hooks.update({ id: this.data.id }, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + }); + + describe('#delete', () => { + const id = 5; + + beforeEach(function () { + this.request = nock(API_URL).delete(`/hooks/${id}`).reply(200); + }); + + it('should accept a callback', function (done) { + this.hooks.delete({ id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.hooks.delete({ id }).then(done.bind(null, null)); + }); + + it(`should perform a delete request to /hooks/${id}`, function (done) { + const { request } = this; + + this.hooks.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete(`/hooks/${id}`).reply(500); + + this.hooks.delete({ id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/hooks/${id}`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + this.hooks.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getSecrets', () => { + const data = { + id: 'hook_id', + }; + + beforeEach(function () { + this.request = nock(API_URL).get(`/hooks/${data.id}/secrets`).reply(200); + }); + + it('should accept a callback', function (done) { + this.hooks.getSecrets(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.hooks.getSecrets(data).then(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/hooks/hook_id/secrets', function (done) { + const { request } = this; + + this.hooks.getSecrets(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/hooks/${data.id}/secrets`).reply(500); + + this.hooks.getSecrets(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/hooks/${data.id}/secrets`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + this.hooks.getSecrets(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#addSecrets', () => { + beforeEach(function () { + this.data = { + id: 'hook_id', + }; + this.body = { permission_name: 'My Permission', resource_server_identifier: 'test123' }; + + this.request = nock(API_URL).post(`/hooks/${this.data.id}/secrets`).reply(200); + }); + + it('should accept a callback', function (done) { + this.hooks.addSecrets(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.hooks.addSecrets(this.data, {}).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/hooks/${this.data.id}/secrets`).reply(500); + + this.hooks.addSecrets(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/hooks/hook_id/secrets', function (done) { + const { request } = this; + + this.hooks.addSecrets(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).post(`/hooks/${this.data.id}/secrets`, this.body).reply(200); + + this.hooks.addSecrets(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/hooks/${this.data.id}/secrets`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.hooks.addSecrets(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateSecrets', () => { + beforeEach(function () { + this.data = { + id: 'hook_id', + }; + this.body = { DB_PASSWORD: 'abcd1234', APITOKEN: 'foosecret' }; + + this.request = nock(API_URL).patch(`/hooks/${this.data.id}/secrets`).reply(200); + }); + + it('should accept a callback', function (done) { + this.hooks.updateSecrets(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.hooks + .updateSecrets(this.data, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/hooks/${this.data.id}/secrets`).reply(500); + + this.hooks.updateSecrets(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/hooks/hook_id/secrets', function (done) { + const { request } = this; + + this.hooks.updateSecrets(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).patch(`/hooks/${this.data.id}/secrets`, this.body).reply(200); + + this.hooks.updateSecrets(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch(`/hooks/${this.data.id}/secrets`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.hooks.updateSecrets(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#removeSecrets', () => { + beforeEach(function () { + this.data = { + id: 'hook_id', + }; + this.body = { DB_PASSWORD: 'abcd1234', APITOKEN: 'foosecret' }; + + this.request = nock(API_URL).delete(`/hooks/${this.data.id}/secrets`, {}).reply(200); + }); + + it('should validate empty hookId', function () { + const _this = this; + expect(() => { + _this.hooks.removeSecrets({ id: null }, _this.body, () => {}); + }).to.throw('The id passed in params cannot be null or undefined'); + }); + + it('should validate non-string hookId', function () { + const _this = this; + expect(() => { + _this.hooks.removeSecrets({ id: 123 }, _this.body, () => {}); + }).to.throw('The hook Id has to be a string'); + }); + + it('should accept a callback', function (done) { + this.hooks.removeSecrets(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.hooks + .removeSecrets(this.data, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/hooks/${this.data.id}/secrets`).reply(500); + + this.hooks.removeSecrets(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a DELETE request to /api/v2/hooks/hook_id/secrets', function (done) { + this.hooks.removeSecrets(this.data, {}).then(() => { + expect(this.request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).delete(`/hooks/${this.data.id}/secrets`, this.body).reply(200); + + this.hooks.removeSecrets(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/hooks/${this.data.id}/secrets`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.hooks.removeSecrets(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); +}); diff --git a/test/management/jobs.tests.js b/test/management/jobs.tests.js index fbd7e00f9..63034999d 100644 --- a/test/management/jobs.tests.js +++ b/test/management/jobs.tests.js @@ -1,101 +1,197 @@ -var path = require('path'); -var expect = require('chai').expect; -var nock = require('nock'); -var extractParts = require('../utils').extractParts; -var fs = require('fs'); +const path = require('path'); +const { expect } = require('chai'); +const nock = require('nock'); +const { extractParts } = require('../utils'); +const fs = require('fs'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var JobsManager = require(SRC_DIR + '/management/JobsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const JobsManager = require(`../../src/management/JobsManager`); +const { ArgumentError } = require('rest-facade'); -var token = 'TOKEN'; +const token = 'TOKEN'; -describe('JobsManager', function() { - before(function() { +describe('JobsManager', () => { + before(function () { this.id = 'testJob'; this.jobs = new JobsManager({ tokenProvider: { - getAccessToken: function() { + getAccessToken() { return Promise.resolve(token); - } + }, }, headers: {}, - baseUrl: API_URL + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['verifyEmail', 'importUsers', 'get']; + describe('instance', () => { + const methods = ['verifyEmail', 'importUsers', 'exportUsers', 'get']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.jobs[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(JobsManager).to.throw(ArgumentError, 'Must provide client options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new JobsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = JobsManager.bind(null, {}); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new JobsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new JobsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); + }); - it('should throw an error when the base URL is invalid', function() { - var client = JobsManager.bind(null, { baseUrl: '' }); + describe('#get', () => { + beforeEach(function () { + this.request = nock(API_URL).get(`/jobs/${this.id}`).reply(200); + }); + + it('should accept a callback', function (done) { + this.jobs.get({ id: this.id }, () => { + done(); + }); + }); - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should return a promise if no callback is given', function (done) { + this.jobs.get({ id: this.id }).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/jobs/${this.id}`).reply(500); + + this.jobs.get({ id: this.id }).catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should throw an ArgumentError if an invalid id is passed', function (done) { + try { + this.jobs.errors({ id: 12345 }, () => {}); + } catch (err) { + expect(err).to.exist; + done(); + } }); - }); - describe('#get', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/jobs/' + this.id) + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const data = [{ test: true }]; + nock(API_URL).get(`/jobs/${this.id}`).reply(200, data); + + this.jobs.get({ id: this.id }).then((blacklistedTokens) => { + expect(blacklistedTokens).to.be.an.instanceOf(Array); + + expect(blacklistedTokens.length).to.equal(data.length); + + expect(blacklistedTokens[0].test).to.equal(data[0].test); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/jobs', function (done) { + const { request } = this; + + this.jobs.get({ id: this.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/jobs/${this.id}`) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); + + this.jobs.get({ id: this.id }).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); }); - it('should accept a callback', function(done) { - this.jobs.get({ id: this.id }, function() { + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/jobs/${this.id}`) + .query({ + include_fields: true, + fields: 'test', + }) + .reply(200); + + this.jobs.get({ id: this.id, include_fields: true, fields: 'test' }).then(() => { + expect(request.isDone()).to.be.true; done(); }); }); + }); - it('should return a promise if no callback is given', function(done) { - this.jobs - .get({ id: this.id }) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + // Error retrieval tests + describe('#errors', () => { + beforeEach(function () { + this.request = nock(API_URL).get(`/jobs/${this.id}/errors`).reply(200); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should accept a callback', function (done) { + this.jobs.errors({ id: this.id }, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.jobs.errors({ id: this.id }).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/jobs/' + this.id) - .reply(500); + nock(API_URL).get(`/jobs/${this.id}/errors`).reply(500); - this.jobs.get({ id: this.id }).catch(function(err) { + this.jobs.errors({ id: this.id }).catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should throw an ArgumentError if an invalid id is passed', function (done) { + try { + this.jobs.errors({ id: null }, () => {}); + } catch (err) { + expect(err).to.exist; + done(); + } + }); + + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/jobs/' + this.id) - .reply(200, data); + const data = [{ test: true }]; + nock(API_URL).get(`/jobs/${this.id}/errors`).reply(200, data); - this.jobs.get({ id: this.id }).then(function(blacklistedTokens) { + this.jobs.errors({ id: this.id }).then((blacklistedTokens) => { expect(blacklistedTokens).to.be.an.instanceOf(Array); expect(blacklistedTokens.length).to.equal(data.length); @@ -106,42 +202,42 @@ describe('JobsManager', function() { }); }); - it('should perform a GET request to /api/v2/jobs', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/jobs/:id/errors', function (done) { + const { request } = this; - this.jobs.get({ id: this.id }).then(function() { + this.jobs.errors({ id: this.id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/jobs/' + this.id) - .matchHeader('Authorization', 'Bearer ' + token) + const request = nock(API_URL) + .get(`/jobs/${this.id}/errors`) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.jobs.get({ id: this.id }).then(function() { + this.jobs.errors({ id: this.id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/jobs/' + this.id) + const request = nock(API_URL) + .get(`/jobs/${this.id}`) .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.jobs.get({ id: this.id, include_fields: true, fields: 'test' }).then(function() { + this.jobs.get({ id: this.id, include_fields: true, fields: 'test' }).then(() => { expect(request.isDone()).to.be.true; done(); }); @@ -150,52 +246,66 @@ describe('JobsManager', function() { const usersFilePath = path.join(__dirname, '../data/users.json'); - describe('#importUsers', function() { - var data = { + describe('#importUsers', () => { + const data = { users: usersFilePath, - connection_id: 'con_test' + connection_id: 'con_test', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/jobs/users-imports') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/jobs/users-imports').reply(200); }); - it('should accept a callback', function(done) { - this.jobs.importUsers(data, function() { + it('should accept a callback', function (done) { + this.jobs.importUsers(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { + this.jobs.importUsers(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should have the payload in response.data', function (done) { + nock.cleanAll(); + const payload = { + status: 'pending', + type: 'users_import', + created_at: '', + id: 'job_0000000000000001', + connection_id: 'con_0000000000000001', + upsert: false, + external_id: '', + send_completion_email: true, + }; + nock(API_URL).post('/jobs/users-imports').reply(200, payload); + this.jobs .importUsers(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + .then((response) => { + expect(response.data).to.deep.equal(payload); + done(); + }) + .catch((err) => done(err)); }); - it('should pass request errors to the promise catch handler', function(done) { + it('should pass request errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/jobs/users-imports') - .replyWithError('printer on fire'); + nock(API_URL).post('/jobs/users-imports').replyWithError('printer on fire'); - this.jobs.importUsers(data).catch(function(err) { + this.jobs.importUsers(data).catch((err) => { expect(err.message).to.equal('printer on fire'); done(); }); }); - it('should pass HTTP errors to the promise catch handler', function(done) { + it('should pass HTTP errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/jobs/users-imports') - .reply(500); + nock(API_URL).post('/jobs/users-imports').reply(500); - this.jobs.importUsers(data).catch(function(err) { + this.jobs.importUsers(data).catch((err) => { expect(err.message).to.equal( 'cannot POST https://tenant.auth0.com/jobs/users-imports (500)' ); @@ -203,60 +313,75 @@ describe('JobsManager', function() { }); }); - it('should perform a POST request to /api/v2/jobs/users-imports', function(done) { - var request = this.request; + it('should pass rest-api json error messages to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL) + .post('/jobs/users-imports') + .reply(() => [ + 429, + { + statusCode: 429, + error: 'Too Many Requests', + message: 'There are 4 active import users jobs', + }, + ]); + + this.jobs.importUsers(data).catch((err) => { + expect(err.message).to.equal( + 'cannot POST https://tenant.auth0.com/jobs/users-imports (429)' + ); + expect(err.text).to.equal('There are 4 active import users jobs'); + done(); + }); + }); + + it('should perform a POST request to /api/v2/jobs/users-imports', function (done) { + const { request } = this; - this.jobs.importUsers(data).then(function() { + this.jobs.importUsers(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should be a multipart request', function(done) { + it('should be a multipart request', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/jobs/users-imports') - .matchHeader('Content-Type', function(header) { - return header.indexOf('multipart/form-data') === 0; - }) + .matchHeader('Content-Type', (header) => header.indexOf('multipart/form-data') === 0) .reply(200); - this.jobs.importUsers(data).then(function() { + this.jobs.importUsers(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should have four parts: connection_id, users file, upsert and send_completion_email', function(done) { + it('should have four parts: connection_id, users file, upsert and send_completion_email', function (done) { nock.cleanAll(); - var boundary = null; + let boundary = null; - var request = nock(API_URL) - .matchHeader('Content-Type', function(header) { - boundary = '--' + header.match(/boundary=([^\n]*)/)[1]; + const request = nock(API_URL) + .matchHeader('Content-Type', (header) => { + boundary = `--${header.match(/boundary=([^\n]*)/)[1]}`; return true; }) - .post('/jobs/users-imports', function(body) { - var parts = extractParts(body, boundary); + .post('/jobs/users-imports', (body) => { + const parts = extractParts(body, boundary); // Validate the connection id. - expect(parts.connection_id) - .to.exist.to.be.a('string') - .to.equal(data.connection_id); + expect(parts.connection_id).to.exist.to.be.a('string').to.equal(data.connection_id); // Validate the upsert param - default is false - expect(parts.upsert) - .to.exist.to.be.a('string') - .to.equal('false'); + expect(parts.upsert).to.exist.to.be.a('string').to.equal('false'); // Validate the send_completion_email param - default is true - expect(parts.send_completion_email) - .to.exist.to.be.a('string') - .to.equal('true'); + expect(parts.send_completion_email).to.exist.to.be.a('string').to.equal('true'); // Validate the content type of the users JSON. expect(parts.users) @@ -272,80 +397,76 @@ describe('JobsManager', function() { }) .reply(200); - this.jobs.importUsers(data).then(function() { + this.jobs.importUsers(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should set upsert parameter correctly', function(done) { + it('should set upsert parameter correctly', function (done) { nock.cleanAll(); - var boundary = null; + let boundary = null; - var request = nock(API_URL) - .matchHeader('Content-Type', function(header) { - boundary = '--' + header.match(/boundary=([^\n]*)/)[1]; + const request = nock(API_URL) + .matchHeader('Content-Type', (header) => { + boundary = `--${header.match(/boundary=([^\n]*)/)[1]}`; return true; }) - .post('/jobs/users-imports', function(body) { - var parts = extractParts(body, boundary); + .post('/jobs/users-imports', (body) => { + const parts = extractParts(body, boundary); // Validate the upsert param - expect(parts.upsert) - .to.exist.to.be.a('string') - .to.equal('true'); + expect(parts.upsert).to.exist.to.be.a('string').to.equal('true'); return true; }) .reply(200); - this.jobs.importUsers(Object.assign({ upsert: true }, data)).then(function() { + this.jobs.importUsers(Object.assign({ upsert: true }, data)).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should set send_completion_email parameter correctly', function(done) { + it('should set send_completion_email parameter correctly', function (done) { nock.cleanAll(); - var boundary = null; + let boundary = null; - var request = nock(API_URL) - .matchHeader('Content-Type', function(header) { - boundary = '--' + header.match(/boundary=([^\n]*)/)[1]; + const request = nock(API_URL) + .matchHeader('Content-Type', (header) => { + boundary = `--${header.match(/boundary=([^\n]*)/)[1]}`; return true; }) - .post('/jobs/users-imports', function(body) { - var parts = extractParts(body, boundary); + .post('/jobs/users-imports', (body) => { + const parts = extractParts(body, boundary); // Validate the upsert param - expect(parts.send_completion_email) - .to.exist.to.be.a('string') - .to.equal('false'); + expect(parts.send_completion_email).to.exist.to.be.a('string').to.equal('false'); return true; }) .reply(200); - this.jobs.importUsers(Object.assign({ send_completion_email: false }, data)).then(function() { + this.jobs.importUsers(Object.assign({ send_completion_email: false }, data)).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/jobs/users-imports') - .matchHeader('Authorization', 'Bearer ' + token) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.jobs.importUsers(data).then(function() { + this.jobs.importUsers(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -353,30 +474,28 @@ describe('JobsManager', function() { }); }); - describe('#importUsers with JSON data', function() { - var data = { + describe('#importUsers with JSON data', () => { + const data = { users_json: fs.readFileSync(usersFilePath, 'utf8'), - connection_id: 'con_test' + connection_id: 'con_test', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/jobs/users-imports') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/jobs/users-imports').reply(200); }); - it('should correctly include user JSON', function(done) { + it('should correctly include user JSON', function (done) { nock.cleanAll(); - var boundary = null; + let boundary = null; - var request = nock(API_URL) - .matchHeader('Content-Type', function(header) { - boundary = '--' + header.match(/boundary=([^\n]*)/)[1]; + const request = nock(API_URL) + .matchHeader('Content-Type', (header) => { + boundary = `--${header.match(/boundary=([^\n]*)/)[1]}`; return true; }) - .post('/jobs/users-imports', function(body) { - var parts = extractParts(body, boundary); + .post('/jobs/users-imports', (body) => { + const parts = extractParts(body, boundary); // Validate the content type of the users JSON. expect(parts.users) @@ -392,7 +511,7 @@ describe('JobsManager', function() { }) .reply(200); - this.jobs.importUsers(data).then(function() { + this.jobs.importUsers(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -400,77 +519,183 @@ describe('JobsManager', function() { }); }); - describe('#verifyEmail', function() { - var data = { - user_id: 'github|12345' + describe('#importUsersJob', () => { + const data = { + users: usersFilePath, + connection_id: 'con_test', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/jobs/verification-email') - .reply(200, data); + beforeEach(function () { + this.request = nock(API_URL).post('/jobs/users-imports').reply(200); }); - it('should accept a callback', function(done) { - this.jobs.verifyEmail(data, function() { + it('should accept a callback', function (done) { + this.jobs.importUsersJob(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { + this.jobs.importUsersJob(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should extract data from the response', function (done) { + nock.cleanAll(); + + const payload = { + status: 'pending', + type: 'users_import', + created_at: '', + id: 'job_0000000000000001', + connection_id: 'con_0000000000000001', + upsert: false, + external_id: '', + send_completion_email: true, + }; + nock(API_URL).post('/jobs/users-imports').reply(200, payload); + this.jobs - .verifyEmail(data) + .importUsersJob(data) + .then((response) => { + expect(response).to.deep.equal(payload); + done(); + }) + .catch((err) => done(err)); + }); + }); + + describe('#exportUsers', () => { + beforeEach(function () { + this.request = nock(API_URL).post('/jobs/users-exports').reply(200); + }); + + it('should accept a callback', function (done) { + this.jobs.exportUsers({ format: 'csv' }, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.jobs + .exportUsers({ format: 'csv' }) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); + nock(API_URL).post('/jobs/users-exports').reply(500); - var request = nock(API_URL) - .post('/jobs/verification-email') - .reply(500); + this.jobs.exportUsers({ format: 'csv' }).catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const data = { + type: 'users_export', + status: 'pending', + format: 'csv', + created_at: '', + id: 'job_0000000000000001', + }; + nock(API_URL).post('/jobs/users-exports').reply(200, data); + + this.jobs.exportUsers({ format: 'csv' }).then((response) => { + expect(response).to.be.an.instanceOf(Object); + expect(response.status).to.equal('pending'); + done(); + }); + }); + + it('should perform a POST request to /api/v2/jobs/users-exports', function (done) { + const { request } = this; + + this.jobs.exportUsers({ format: 'csv' }).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + const request = nock(API_URL) + .post('/jobs/users-exports') + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + this.jobs.exportUsers({ format: 'csv' }).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + }); - this.jobs.verifyEmail(data).catch(function(err) { + describe('#verifyEmail', () => { + const data = { + user_id: 'github|12345', + }; + + beforeEach(function () { + this.request = nock(API_URL).post('/jobs/verification-email').reply(200, data); + }); + + it('should accept a callback', function (done) { + this.jobs.verifyEmail(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.jobs.verifyEmail(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post('/jobs/verification-email').reply(500); + + this.jobs.verifyEmail(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/jobs/verification-email', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/jobs/verification-email', function (done) { + const { request } = this; - this.jobs.verifyEmail(data).then(function() { + this.jobs.verifyEmail(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/jobs/verification-email', data) - .reply(200); + const request = nock(API_URL).post('/jobs/verification-email', data).reply(200); - this.jobs.verifyEmail(data).then(function() { + this.jobs.verifyEmail(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/jobs/verification-email') - .matchHeader('Authorization', 'Bearer ' + token) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.jobs.verifyEmail(data).then(function() { + this.jobs.verifyEmail(data).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/management/log-streams.tests.js b/test/management/log-streams.tests.js new file mode 100644 index 000000000..35e49661c --- /dev/null +++ b/test/management/log-streams.tests.js @@ -0,0 +1,379 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenant.auth0.com'; + +const LogStreamsManager = require(`../../src/management/LogStreamsManager`); +const { ArgumentError } = require('rest-facade'); + +describe('LogStreamsManager', () => { + before(function () { + this.token = 'TOKEN'; + this.logStreams = new LogStreamsManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = ['getAll', 'get', 'create', 'update', 'delete']; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.logStreams[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new LogStreamsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new LogStreamsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new LogStreamsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/log-streams').reply(200); + }); + + it('should accept a callback', function (done) { + this.logStreams.getAll(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.logStreams.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/log-streams').reply(500); + + this.logStreams.getAll().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const data = [{ test: true }]; + nock(API_URL).get('/log-streams').reply(200, data); + + this.logStreams.getAll().then((logStreams) => { + expect(logStreams).to.be.an.instanceOf(Array); + + expect(logStreams.length).to.equal(data.length); + + expect(logStreams[0].test).to.equal(data[0].test); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/log-streams', function (done) { + const { request } = this; + + this.logStreams.getAll().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/log-streams') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.logStreams.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + }); + + describe('#get', () => { + const params = { id: 5 }; + const data = { + id: params.id, + name: 'Test log', + }; + + beforeEach(function () { + this.request = nock(API_URL).get(`/log-streams/${data.id}`).reply(200); + }); + + it('should accept a callback', function (done) { + this.logStreams.get(params, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.logStreams.get(params).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/log-streams/${params.id}`).reply(500); + + this.logStreams.get().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/log-streams/${params.id}`).reply(200, data); + + this.logStreams.get(params).then((log) => { + expect(log.id).to.equal(data.id); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/log-streams/:id', function (done) { + const { request } = this; + + this.logStreams.get(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/log-streams') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.logStreams.getAll().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/log-streams') + .query({ + include_fields: true, + fields: 'test', + }) + .reply(200); + + this.logStreams.getAll({ include_fields: true, fields: 'test' }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#create', () => { + const data = { + name: 'Test log stream', + }; + beforeEach(function () { + this.request = nock(API_URL).post('/log-streams').reply(200); + }); + + it('should accept a callback', function (done) { + this.logStreams.create(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.logStreams.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post('/log-streams').reply(500); + + this.logStreams.create(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/log-streams', function (done) { + const { request } = this; + + this.logStreams.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).post('/log-streams', data).reply(200); + + this.logStreams.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post('/log-streams') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.logStreams.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#update', () => { + beforeEach(function () { + this.data = { id: 5 }; + + this.request = nock(API_URL).patch(`/log-streams/${this.data.id}`).reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.logStreams.update({ id: 5 }, {}, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.logStreams + .update({ id: 5 }, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PATCH request to /api/v2/log-streams/5', function (done) { + const { request } = this; + + this.logStreams.update({ id: 5 }, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).patch(`/log-streams/${this.data.id}`, this.data).reply(200); + + this.logStreams.update({ id: 5 }, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/log-streams/${this.data.id}`).reply(500); + + this.logStreams.update({ id: this.data.id }, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + }); + + describe('#delete', () => { + const id = 5; + + beforeEach(function () { + this.request = nock(API_URL).delete(`/log-streams/${id}`).reply(200); + }); + + it('should accept a callback', function (done) { + this.logStreams.delete({ id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.logStreams.delete({ id }).then(done.bind(null, null)); + }); + + it(`should perform a delete request to /log-streams/${id}`, function (done) { + const { request } = this; + + this.logStreams.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete(`/log-streams/${id}`).reply(500); + + this.logStreams.delete({ id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/log-streams/${id}`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + this.logStreams.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); +}); diff --git a/test/management/logs.tests.js b/test/management/logs.tests.js index 37e6ed5e6..7aba08ecf 100644 --- a/test/management/logs.tests.js +++ b/test/management/logs.tests.js @@ -1,92 +1,84 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var LogsManager = require(SRC_DIR + '/management/LogsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const LogsManager = require(`../../src/management/LogsManager`); +const { ArgumentError } = require('rest-facade'); -describe('LogsManager', function() { - before(function() { +describe('LogsManager', () => { + before(function () { this.token = 'TOKEN'; this.logs = new LogsManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['getAll', 'get']; + describe('instance', () => { + const methods = ['getAll', 'get']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.logs[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(LogsManager).to.throw(ArgumentError, 'Must provide client options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new LogsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = LogsManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new LogsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = LogsManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new LogsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/logs') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/logs').reply(200); }); - it('should accept a callback', function(done) { - this.logs.getAll(function() { + it('should accept a callback', function (done) { + this.logs.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.logs - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.logs.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/logs') - .reply(500); + nock(API_URL).get('/logs').reply(500); - this.logs.getAll().catch(function(err) { + this.logs.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/logs') - .reply(200, data); + const data = [{ test: true }]; + nock(API_URL).get('/logs').reply(200, data); - this.logs.getAll().then(function(logs) { + this.logs.getAll().then((logs) => { expect(logs).to.be.an.instanceOf(Array); expect(logs.length).to.equal(data.length); @@ -97,42 +89,42 @@ describe('LogsManager', function() { }); }); - it('should perform a GET request to /api/v2/logs', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/logs', function (done) { + const { request } = this; - this.logs.getAll().then(function() { + this.logs.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/logs') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.logs.getAll().then(function() { + this.logs.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/logs') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.logs.getAll({ include_fields: true, fields: 'test' }).then(function() { + this.logs.getAll({ include_fields: true, fields: 'test' }).then(() => { expect(request.isDone()).to.be.true; done(); @@ -140,97 +132,88 @@ describe('LogsManager', function() { }); }); - describe('#get', function() { - var params = { id: 5 }; - var data = { + describe('#get', () => { + const params = { id: 5 }; + const data = { id: params.id, - name: 'Test log' + name: 'Test log', }; - beforeEach(function() { - this.request = nock(API_URL) - .get('/logs/' + data.id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).get(`/logs/${data.id}`).reply(200); }); - it('should accept a callback', function(done) { - this.logs.get(params, function() { + it('should accept a callback', function (done) { + this.logs.get(params, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.logs - .get(params) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.logs.get(params).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/logs/' + params.id) - .reply(500); + nock(API_URL).get(`/logs/${params.id}`).reply(500); - this.logs.get().catch(function(err) { + this.logs.get().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/logs/' + params.id) - .reply(200, data); + nock(API_URL).get(`/logs/${params.id}`).reply(200, data); - this.logs.get(params).then(function(log) { + this.logs.get(params).then((log) => { expect(log.id).to.equal(data.id); done(); }); }); - it('should perform a GET request to /api/v2/logs/:id', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/logs/:id', function (done) { + const { request } = this; - this.logs.get(params).then(function() { + this.logs.get(params).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/logs') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.logs.getAll().then(function() { + this.logs.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/logs') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.logs.getAll({ include_fields: true, fields: 'test' }).then(function() { + this.logs.getAll({ include_fields: true, fields: 'test' }).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/management/management-client.tests.js b/test/management/management-client.tests.js index 86ef52613..8b38001af 100644 --- a/test/management/management-client.tests.js +++ b/test/management/management-client.tests.js @@ -1,168 +1,856 @@ -var expect = require('chai').expect; -var assign = Object.assign || require('object.assign'); - -var ManagementClient = require('../../src/management'); - -var ArgumentError = require('rest-facade').ArgumentError; -var UsersManager = require('../../src/management/UsersManager'); -var BlacklistedTokensManager = require('../../src/management/BlacklistedTokensManager'); -var ClientsManager = require('../../src/management/ClientsManager'); -var ClientGrantsManager = require('../../src/management/ClientGrantsManager'); -var ConnectionsManager = require('../../src/management/ConnectionsManager'); -var DeviceCredentialsManager = require('../../src/management/DeviceCredentialsManager'); -var EmailProviderManager = require('../../src/management/EmailProviderManager'); -var JobsManager = require('../../src/management/JobsManager'); -var RulesManager = require('../../src/management/RulesManager'); -var StatsManager = require('../../src/management/StatsManager'); -var RulesConfigsManager = require('../../src/management/RulesConfigsManager'); - -var TenantManager = require('../../src/management/TenantManager'); - -describe('ManagementClient', function() { - var withTokenProviderConfig = { +const { expect } = require('chai'); +const nock = require('nock'); +const sinon = require('sinon'); +const proxyquire = require('proxyquire'); + +const ManagementClient = require('../../src/management'); + +const { ArgumentError } = require('rest-facade'); +const UsersManager = require('../../src/management/UsersManager'); +const UserBlocksManager = require('../../src/management/UserBlocksManager'); +const BlacklistedTokensManager = require('../../src/management/BlacklistedTokensManager'); +const ClientsManager = require('../../src/management/ClientsManager'); +const ClientGrantsManager = require('../../src/management/ClientGrantsManager'); +const GrantsManager = require('../../src/management/GrantsManager'); +const ConnectionsManager = require('../../src/management/ConnectionsManager'); +const DeviceCredentialsManager = require('../../src/management/DeviceCredentialsManager'); +const EmailProviderManager = require('../../src/management/EmailProviderManager'); +const EmailTemplatesManager = require('../../src/management/EmailTemplatesManager'); +const JobsManager = require('../../src/management/JobsManager'); +const RulesManager = require('../../src/management/RulesManager'); +const StatsManager = require('../../src/management/StatsManager'); +const RulesConfigsManager = require('../../src/management/RulesConfigsManager'); +const TenantManager = require('../../src/management/TenantManager'); + +describe('ManagementClient', () => { + const withTokenProviderConfig = { clientId: 'clientId', clientSecret: 'clientSecret', - domain: 'auth0-node-sdk.auth0.com' + domain: 'auth0-node-sdk.auth0.com', + tokenProvider: { + enableCache: false, + }, }; - var withTokenConfig = { + const withTokenConfig = { domain: 'auth0-node-sdk.auth0.com', - token: 'fake-token' + token: 'fake-token', }; - it('should expose an instance of ManagementClient when withTokenConfig is passed', function() { + it('should expose an instance of ManagementClient when withTokenConfig is passed', () => { expect(new ManagementClient(withTokenConfig)).to.exist.to.be.an.instanceOf(ManagementClient); }); - it('should expose an instance of ManagementClient when withTokenProviderConfig is passed', function() { + it('should expose an instance of ManagementClient when withTokenProviderConfig is passed', () => { expect(new ManagementClient(withTokenProviderConfig)).to.exist.to.be.an.instanceOf( ManagementClient ); }); - it('should expose an instance of ManagementClient when withTokenProviderConfig and audience is passed', function() { - var config = assign({ audience: 'https://auth0-node-sdk.auth0.com/api/v2/' }, withTokenConfig); + it('should expose an instance of ManagementClient when withTokenProviderConfig and audience is passed', () => { + const config = Object.assign( + { audience: 'https://auth0-node-sdk.auth0.com/api/v2/' }, + withTokenConfig + ); expect(new ManagementClient(config)).to.exist.to.be.an.instanceOf(ManagementClient); }); - it('should raise an error when no options object is provided', function() { - expect(ManagementClient).to.throw( - ArgumentError, - 'Management API SDK options must be an object' - ); + it('should raise an error when no options object is provided', () => { + expect(() => { + new ManagementClient(); + }).to.throw(ArgumentError, 'Management API SDK options must be an object'); }); - it('should raise an error when the domain is not set', function() { - var config = assign({}, withTokenConfig); - delete config.domain; - var client = ManagementClient.bind(null, config); + it('should raise an error when the domain is not set', () => { + const options = Object.assign({}, withTokenConfig); + delete options.domain; - expect(client).to.throw(ArgumentError, 'Must provide a domain'); + expect(() => { + new ManagementClient(options); + }).to.throw(ArgumentError, 'Must provide a domain'); }); - it('should raise an error when the domain is not valid', function() { - var config = assign({}, withTokenConfig); - config.domain = ''; - var client = ManagementClient.bind(null, config); + it('should raise an error when the domain is not valid', () => { + const options = Object.assign({}, withTokenConfig); + options.domain = ''; - expect(client).to.throw(ArgumentError, 'Must provide a domain'); + expect(() => { + new ManagementClient(options); + }).to.throw(ArgumentError, 'Must provide a domain'); }); - it('should raise an error when the token is not valid', function() { - var config = assign({}, withTokenConfig); - config.token = ''; - var client = ManagementClient.bind(null, config); + it('should raise an error when the token is not valid', () => { + const options = Object.assign({}, withTokenConfig); + options.token = ''; - expect(client).to.throw(ArgumentError, 'Must provide a token'); + expect(() => { + new ManagementClient(options); + }).to.throw(ArgumentError, 'Must provide a token'); }); - it('should raise an error when the token and clientId are not set', function() { - var config = assign({}, withTokenProviderConfig); - delete config.clientId; - var client = ManagementClient.bind(null, config); + it('should raise an error when the token and clientId are not set', () => { + const options = Object.assign({}, withTokenProviderConfig); + delete options.clientId; - expect(client).to.throw(ArgumentError, 'Must provide a clientId'); + expect(() => { + new ManagementClient(options); + }).to.throw(ArgumentError, 'Must provide a clientId'); }); - it('should raise an error when the token and clientSecret are not set', function() { - var config = assign({}, withTokenProviderConfig); - delete config.clientSecret; - var client = ManagementClient.bind(null, config); + it('should raise an error when the token and clientSecret are not set', () => { + const options = Object.assign({}, withTokenProviderConfig); + delete options.clientSecret; - expect(client).to.throw(ArgumentError, 'Must provide a clientSecret'); + expect(() => { + new ManagementClient(options); + }).to.throw(ArgumentError, 'Must provide a clientSecret'); }); - describe('instance properties', function() { - var manager; - var managers = { + describe('getAccessToken', () => { + it('should return token provided in config', (done) => { + const config = Object.assign({}, withTokenConfig); + const client = new ManagementClient(config); + + client.getAccessToken().then((accessToken) => { + expect(accessToken).to.equal(withTokenConfig.token); + done(); + }); + }); + it('should return token from provider', (done) => { + const config = Object.assign({}, withTokenProviderConfig); + const client = new ManagementClient(config); + + nock(`https://${config.domain}`) + .post('/oauth/token', (body) => { + expect(body.client_id).to.equal(config.clientId); + expect(body.client_secret).to.equal(config.clientSecret); + expect(body.grant_type).to.equal('client_credentials'); + return true; + }) + .reply((uri, requestBody, cb) => + cb(null, [200, { access_token: 'token', expires_in: 3600 }]) + ); + + client.getAccessToken().then((data) => { + expect(data).to.equal('token'); + done(); + nock.cleanAll(); + }); + }); + }); + + describe('instance properties', () => { + let manager; + const managers = { UsersManager: { property: 'users', - cls: UsersManager + cls: UsersManager, + }, + UserBlocksManager: { + property: 'userBlocks', + cls: UserBlocksManager, }, BlacklistedTokensManager: { property: 'blacklistedTokens', - cls: BlacklistedTokensManager + cls: BlacklistedTokensManager, }, ClientsManager: { property: 'clients', - cls: ClientsManager + cls: ClientsManager, }, ClientGrantsManager: { property: 'clientGrants', - cls: ClientGrantsManager + cls: ClientGrantsManager, + }, + GrantsManager: { + property: 'grants', + cls: GrantsManager, }, ConnectionsManager: { property: 'connections', - cls: ConnectionsManager + cls: ConnectionsManager, }, DeviceCredentialsManager: { property: 'deviceCredentials', - cls: DeviceCredentialsManager + cls: DeviceCredentialsManager, }, EmailProviderManager: { property: 'emailProvider', - cls: EmailProviderManager + cls: EmailProviderManager, + }, + EmailTemplatesManager: { + property: 'emailTemplates', + cls: EmailTemplatesManager, }, JobsManager: { property: 'jobs', - cls: JobsManager + cls: JobsManager, }, RulesManager: { property: 'rules', - cls: RulesManager + cls: RulesManager, }, StatsManager: { property: 'stats', - cls: StatsManager + cls: StatsManager, }, TenantManager: { property: 'tenant', - cls: TenantManager + cls: TenantManager, }, - 'RulesConfigsManager': { + RulesConfigsManager: { property: 'rulesConfigs', - cls: RulesConfigsManager + cls: RulesConfigsManager, }, }; - before(function() { - var config = assign({}, withTokenConfig); + describe('user agent', () => { + for (const name in managers) { + manager = managers[name]; + + it(`${manager} should use the node version by default`, () => { + const client = new ManagementClient(withTokenConfig); + + expect( + client[manager.property].resource.restClient.restClient.options.headers + ).to.contain({ + 'User-Agent': `node.js/${process.version.replace('v', '')}`, + }); + }); + + it(`${manager} should include additional headers when provided`, () => { + const customHeaders = { + 'User-Agent': 'my-user-agent', + 'Another-header': 'test-header', + }; + + const options = Object.assign({ headers: customHeaders }, withTokenConfig); + const client = new ManagementClient(options); + + expect( + client[manager.property].resource.restClient.restClient.options.headers + ).to.contain({ + 'User-Agent': 'my-user-agent', + 'Another-header': 'test-header', + }); + }); + } + }); + + describe('client info', () => { + it('should configure instances with default telemetry header', () => { + const utilsStub = { + generateClientInfo: sinon.spy(() => ({ name: 'test-sdk', version: 'ver-123' })), + }; + const ManagementClientProxy = proxyquire('../../src/management/', { + '../utils': utilsStub, + }); + const client = new ManagementClientProxy(withTokenConfig); + + const requestHeaders = { + 'Auth0-Client': 'eyJuYW1lIjoidGVzdC1zZGsiLCJ2ZXJzaW9uIjoidmVyLTEyMyJ9', + 'Content-Type': 'application/json', + }; + + expect(client.clients.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.clientGrants.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.grants.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.users.users.restClient.restClient.options.headers).to.contain(requestHeaders); + expect(client.users.multifactor.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.users.identities.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.users.userLogs.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.users.enrollments.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.users.usersByEmail.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect( + client.users.recoveryCodeRegenerations.restClient.restClient.options.headers + ).to.contain(requestHeaders); + expect( + client.users.invalidateRememberBrowsers.restClient.restClient.options.headers + ).to.contain(requestHeaders); + expect(client.users.roles.restClient.restClient.options.headers).to.contain(requestHeaders); + expect(client.users.permissions.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.guardian.enrollments.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.guardian.tickets.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.guardian.factors.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.guardian.factorsTemplates.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.guardian.factorsProviders.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect( + client.guardian.factorsPhoneSelectedProvider.restClient.restClient.options.headers + ).to.contain(requestHeaders); + expect( + client.guardian.factorsPhoneMessageTypes.restClient.restClient.options.headers + ).to.contain(requestHeaders); + + expect(client.customDomains.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect( + client.customDomains.vefifyResource.restClient.restClient.options.headers + ).to.contain(requestHeaders); + + expect(client.connections.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.deviceCredentials.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.rules.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.blacklistedTokens.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.emailProvider.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.emailTemplates.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.stats.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.tenant.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.jobs.jobs.restClient.restClient.options.headers).to.contain(requestHeaders); + expect(client.jobs.usersExports.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.tickets.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.logs.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.resourceServers.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.emailTemplates.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.rulesConfigs.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.roles.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.roles.permissions.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.roles.users.restClient.restClient.options.headers).to.contain(requestHeaders); + }); + + it('should configure instances with custom telemetry header', () => { + const customTelemetry = { name: 'custom', version: 'beta-01', env: { node: 'v10' } }; + const client = new ManagementClient({ + token: 'token', + domain: 'auth0.com', + clientInfo: customTelemetry, + }); + + const requestHeaders = { + 'Auth0-Client': + 'eyJuYW1lIjoiY3VzdG9tIiwidmVyc2lvbiI6ImJldGEtMDEiLCJlbnYiOnsibm9kZSI6InYxMCJ9fQ', + 'Content-Type': 'application/json', + }; + + expect(client.clients.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.clientGrants.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.grants.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.users.users.restClient.restClient.options.headers).to.contain(requestHeaders); + expect(client.users.multifactor.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.users.identities.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.users.userLogs.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.users.enrollments.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.users.usersByEmail.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect( + client.users.recoveryCodeRegenerations.restClient.restClient.options.headers + ).to.contain(requestHeaders); + expect( + client.users.invalidateRememberBrowsers.restClient.restClient.options.headers + ).to.contain(requestHeaders); + expect(client.users.roles.restClient.restClient.options.headers).to.contain(requestHeaders); + expect(client.users.permissions.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.guardian.enrollments.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.guardian.tickets.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.guardian.factors.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.guardian.factorsTemplates.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.guardian.factorsProviders.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect( + client.guardian.factorsPhoneSelectedProvider.restClient.restClient.options.headers + ).to.contain(requestHeaders); + expect( + client.guardian.factorsPhoneMessageTypes.restClient.restClient.options.headers + ).to.contain(requestHeaders); + + expect(client.customDomains.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect( + client.customDomains.vefifyResource.restClient.restClient.options.headers + ).to.contain(requestHeaders); + + expect(client.connections.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.deviceCredentials.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.rules.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.blacklistedTokens.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.emailProvider.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.emailTemplates.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.stats.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.tenant.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.jobs.jobs.restClient.restClient.options.headers).to.contain(requestHeaders); + expect(client.jobs.usersExports.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.tickets.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.logs.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.resourceServers.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.emailTemplates.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.rulesConfigs.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + + expect(client.roles.resource.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.roles.permissions.restClient.restClient.options.headers).to.contain( + requestHeaders + ); + expect(client.roles.users.restClient.restClient.options.headers).to.contain(requestHeaders); + }); + + it('should configure instances without telemetry when "name" property is empty', () => { + const customTelemetry = { name: '', version: 'beta-01', env: { node: 'v10' } }; + const client = new ManagementClient({ + token: 'token', + domain: 'auth0.com', + clientInfo: customTelemetry, + }); + + expect(client.clients.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect( + client.clientGrants.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect(client.grants.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.users.users.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.multifactor.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.identities.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.userLogs.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.enrollments.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect( + client.users.usersByEmail.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.users.recoveryCodeRegenerations.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.users.invalidateRememberBrowsers.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect(client.users.roles.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.permissions.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect( + client.guardian.enrollments.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect(client.guardian.tickets.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.guardian.factors.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect( + client.guardian.factorsTemplates.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.guardian.factorsProviders.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.guardian.factorsPhoneSelectedProvider.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.guardian.factorsPhoneMessageTypes.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.customDomains.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.customDomains.vefifyResource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.connections.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.deviceCredentials.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect(client.rules.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect( + client.blacklistedTokens.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.emailProvider.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.emailTemplates.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect(client.stats.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.tenant.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.jobs.jobs.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.jobs.usersExports.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.tickets.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.logs.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect( + client.resourceServers.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.emailTemplates.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.rulesConfigs.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect(client.roles.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.roles.permissions.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.roles.users.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + }); + + it('should configure instances without telemetry header when disabled', () => { + const client = new ManagementClient({ + token: 'token', + domain: 'auth0.com', + telemetry: false, + }); + + expect(client.clients.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect( + client.clientGrants.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect(client.grants.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.users.users.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.multifactor.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.identities.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.userLogs.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.enrollments.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect( + client.users.usersByEmail.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.users.recoveryCodeRegenerations.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.users.invalidateRememberBrowsers.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect(client.users.roles.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.users.permissions.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect( + client.guardian.enrollments.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect(client.guardian.tickets.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.guardian.factors.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect( + client.guardian.factorsTemplates.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.guardian.factorsProviders.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.guardian.factorsPhoneSelectedProvider.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.guardian.factorsPhoneMessageTypes.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.customDomains.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + expect( + client.customDomains.vefifyResource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.connections.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.deviceCredentials.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect(client.rules.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect( + client.blacklistedTokens.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.emailProvider.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.emailTemplates.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect(client.stats.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.tenant.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.jobs.jobs.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.jobs.usersExports.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.tickets.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect(client.logs.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + + expect( + client.resourceServers.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.emailTemplates.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect( + client.rulesConfigs.resource.restClient.restClient.options.headers + ).to.not.have.property('Auth0-Client'); + + expect(client.roles.resource.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.roles.permissions.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + expect(client.roles.users.restClient.restClient.options.headers).to.not.have.property( + 'Auth0-Client' + ); + }); + }); + + before(function () { + const config = Object.assign({}, withTokenConfig); this.client = new ManagementClient(config); }); // Tests common to all managers. - for (var name in managers) { + for (const name in managers) { manager = managers[name]; - it('should expose an instance of ' + name, function() { + it(`should expose an instance of ${name}`, function () { expect(this.client[manager.property]).to.exist.to.be.an.instanceOf(manager.cls); }); } }); - describe('instance methods', function() { - var method; - var methods = [ + describe('instance methods', () => { + const methods = [ 'getConnections', 'createConnection', 'getConnection', @@ -177,6 +865,8 @@ describe('ManagementClient', function() { 'createClientGrant', 'updateClientGrant', 'deleteClientGrant', + 'getGrants', + 'deleteGrant', 'createDevicePublicKey', 'getDeviceCredentials', 'deleteDeviceCredential', @@ -188,11 +878,14 @@ describe('ManagementClient', function() { 'getUsers', 'getUser', 'deleteAllUsers', - 'deleteUsers', + 'deleteUser', 'createUser', 'updateUser', 'getBlacklistedTokens', 'blacklistToken', + 'createEmailTemplate', + 'getEmailTemplate', + 'updateEmailTemplate', 'getEmailProvider', 'configureEmailProvider', 'deleteEmailProvider', @@ -205,20 +898,71 @@ describe('ManagementClient', function() { 'deleteUserMultifcator', 'setRulesConfig', 'getRulesConfigs', - 'deleteRulesConfig' + 'deleteRulesConfig', + 'createGuardianEnrollmentTicket', + 'getGuardianFactors', + 'getGuardianFactorSettings', + 'getGuardianFactorProvider', + 'updateGuardianFactorProvider', + 'updateGuardianFactorSettings', + 'getGuardianFactorTemplates', + 'updateGuardianFactorTemplates', + 'updateGuardianFactor', + 'getGuardianPolicies', + 'updateGuardianPolicies', + 'getGuardianPhoneFactorSelectedProvider', + 'updateGuardianPhoneFactorSelectedProvider', + 'getGuardianPhoneFactorMessageTypes', + 'updateGuardianPhoneFactorMessageTypes', + 'getUserBlocks', + 'unblockUser', + 'getUserBlocksByIdentifier', + 'unblockUserByIdentifier', + 'getAccessToken', + 'getPromptsSettings', + 'updatePromptsSettings', ]; - before(function() { - var config = assign({}, withTokenConfig); + before(function () { + const config = Object.assign({}, withTokenConfig); this.client = new ManagementClient(config); }); - for (var i = 0, l = methods.length; i < l; i++) { - method = methods[i]; - - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.client[method]).to.exist.to.be.an.instanceOf(Function); }); - } + }); + + it('should assign roles to a user', function () { + sinon.stub(this.client.users, 'assignRoles'); + this.client.assignRolestoUser(); + expect(this.client.users.assignRoles.called).ok; + this.client.users.assignRoles.reset(); + }); + + it('should include response headers in response', async function () { + const config = Object.assign({}, withTokenConfig, { includeResponseHeaders: true }); + this.client = new ManagementClient(config); + + nock('https://auth0-node-sdk.auth0.com').get(`/api/v2/users`).reply(200, { data: 'value' }); + + const { data, headers } = await this.client.users.getAll(); + expect(data).to.deep.equal({ data: 'value' }); + expect(headers).to.deep.equal({ 'content-type': 'application/json' }); + nock.cleanAll(); + }); + + it('should include response headers in response for shorthand method', async function () { + const config = Object.assign({}, withTokenConfig, { includeResponseHeaders: true }); + this.client = new ManagementClient(config); + + nock('https://auth0-node-sdk.auth0.com').get(`/api/v2/users`).reply(200, { data: 'value' }); + + const { data, headers } = await this.client.getUsers(); + expect(data).to.deep.equal({ data: 'value' }); + expect(headers).to.deep.equal({ 'content-type': 'application/json' }); + nock.cleanAll(); + }); }); }); diff --git a/test/management/management-token-provider.tests.js b/test/management/management-token-provider.tests.js index d7a18cd88..a6b1b0958 100644 --- a/test/management/management-token-provider.tests.js +++ b/test/management/management-token-provider.tests.js @@ -1,411 +1,437 @@ -var expect = require('chai').expect; -var nock = require('nock'); -var assign = Object.assign || require('object.assign'); -var ArgumentError = require('rest-facade').ArgumentError; -var APIError = require('rest-facade').APIError; +const { expect } = require('chai'); +const nock = require('nock'); +const sinon = require('sinon'); +const { ArgumentError } = require('rest-facade'); +const { SanitizedError } = require('../../src/errors'); -var ManagementTokenProvider = require('../../src/management/ManagementTokenProvider'); +const ManagementTokenProvider = require('../../src/management/ManagementTokenProvider'); -describe('ManagementTokenProvider', function() { - var defaultConfig = { +describe('ManagementTokenProvider', () => { + const defaultOptions = { clientId: 'clientId', clientSecret: 'clientSecret', domain: 'auth0-node-sdk.auth0.com', - audience: 'https://auth0-node-sdk.auth0.com/api/v2/' + audience: 'https://auth0-node-sdk.auth0.com/api/v2/', }; - it('should expose an instance of ManagementTokenProvider', function() { - expect(new ManagementTokenProvider(defaultConfig)).to.exist.to.be.an.instanceOf( + it('should expose an instance of ManagementTokenProvider', () => { + expect(new ManagementTokenProvider(defaultOptions)).to.exist.to.be.an.instanceOf( ManagementTokenProvider ); }); - it('should raise an error when no options object is provided', function() { - expect(ManagementTokenProvider).to.throw(ArgumentError, 'Options must be an object'); + it('should raise an error when no options object is provided', () => { + expect(() => { + new ManagementTokenProvider(); + }).to.throw(ArgumentError, 'Options must be an object'); }); - it('should raise an error when domain is not set', function() { - var config = assign({}, defaultConfig); - delete config.domain; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when domain is not set', () => { + const options = Object.assign({}, defaultOptions); + delete options.domain; - expect(provider).to.throw(ArgumentError, 'Must provide a domain'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'Must provide a domain'); }); - it('should raise an error when domain is not valid', function() { - var config = assign({}, defaultConfig); - config.domain = ''; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when domain is not valid', () => { + const options = { ...defaultOptions, domain: '' }; - expect(provider).to.throw(ArgumentError, 'Must provide a domain'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'Must provide a domain'); }); - it('should raise an error when clientId is not set', function() { - var config = assign({}, defaultConfig); - delete config.clientId; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when clientId is not set', () => { + const options = { ...defaultOptions }; + delete options.clientId; - expect(provider).to.throw(ArgumentError, 'Must provide a clientId'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'Must provide a clientId'); }); - it('should raise an error when clientId is not valid', function() { - var config = assign({}, defaultConfig); - config.clientId = ''; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when clientId is not valid', () => { + const options = { ...defaultOptions, clientId: '' }; - expect(provider).to.throw(ArgumentError, 'Must provide a clientId'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'Must provide a clientId'); }); - it('should raise an error when clientSecret is not set', function() { - var config = assign({}, defaultConfig); - delete config.clientSecret; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when clientSecret is not set', () => { + const options = Object.assign({}, defaultOptions); + delete options.clientSecret; - expect(provider).to.throw(ArgumentError, 'Must provide a clientSecret'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'Must provide a clientSecret'); }); - it('should raise an error when clientSecret is not valid', function() { - var config = assign({}, defaultConfig); - config.clientSecret = ''; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when clientSecret is not valid', () => { + const options = { ...defaultOptions, clientSecret: '' }; - expect(provider).to.throw(ArgumentError, 'Must provide a clientSecret'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'Must provide a clientSecret'); }); - it('should raise an error when enableCache is not of type boolean', function() { - var config = assign({}, defaultConfig); - config.enableCache = 'string'; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when enableCache is not of type boolean', () => { + const options = { ...defaultOptions, enableCache: 'string' }; - expect(provider).to.throw(ArgumentError, 'enableCache must be a boolean'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'enableCache must be a boolean'); }); - it('should raise an error when scope is not of type string', function() { - var config = assign({}, defaultConfig); - config.scope = ['foo', 'bar']; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when scope is not of type string', () => { + const options = { ...defaultOptions, scope: ['foo', 'bar'] }; - expect(provider).to.throw(ArgumentError, 'scope must be a string'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'scope must be a string'); }); - it('should set scope to read:users when passed as read:users', function() { - var config = assign({}, defaultConfig); - config.scope = 'read:users'; - var provider = new ManagementTokenProvider(config); + it('should set scope to read:users when passed as read:users', () => { + const options = Object.assign({}, defaultOptions); + options.scope = 'read:users'; + const provider = new ManagementTokenProvider(options); expect(provider.options.scope).to.be.equal('read:users'); }); - it('should set enableCache to true when not specified', function() { - var config = assign({}, defaultConfig); - delete config.enableCache; - var provider = new ManagementTokenProvider(config); + it('should set enableCache to true when not specified', () => { + const options = Object.assign({}, defaultOptions); + delete options.enableCache; + const provider = new ManagementTokenProvider(options); expect(provider.options.enableCache).to.be.true; }); - it('should set enableCache to true when passed as true', function() { - var config = assign({}, defaultConfig); - config.enableCache = true; - var provider = new ManagementTokenProvider(config); + it('should set enableCache to true when passed as true', () => { + const options = Object.assign({}, defaultOptions); + options.enableCache = true; + const provider = new ManagementTokenProvider(options); expect(provider.options.enableCache).to.be.true; }); - it('should set enableCache to false when passed as false', function() { - var config = assign({}, defaultConfig); - config.enableCache = false; - var provider = new ManagementTokenProvider(config); + it('should set enableCache to false when passed as false', () => { + const options = Object.assign({}, defaultOptions); + options.enableCache = false; + const provider = new ManagementTokenProvider(options); expect(provider.options.enableCache).to.be.false; }); - it('should raise an error when the cacheTTLInSeconds is not of type number', function() { - var config = assign({}, defaultConfig); - config.cacheTTLInSeconds = 'string'; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when the cacheTTLInSeconds is not of type number', () => { + const options = { ...defaultOptions, cacheTTLInSeconds: 'string' }; - expect(provider).to.throw(ArgumentError, 'cacheTTLInSeconds must be a number'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'cacheTTLInSeconds must be a number'); }); - it('should raise an error when the cacheTTLInSeconds is not a greater than 0', function() { - var config = assign({}, defaultConfig); - config.cacheTTLInSeconds = -1; - var provider = ManagementTokenProvider.bind(null, config); + it('should raise an error when the cacheTTLInSeconds is not a greater than 0', () => { + const options = { ...defaultOptions, cacheTTLInSeconds: -1 }; - expect(provider).to.throw(ArgumentError, 'cacheTTLInSeconds must be a greater than 0'); + expect(() => { + new ManagementTokenProvider(options); + }).to.throw(ArgumentError, 'cacheTTLInSeconds must be a greater than 0'); }); - it('should set cacheTTLInSeconds to 15 when passed as 15', function() { - var config = assign({}, defaultConfig); - config.cacheTTLInSeconds = 15; - var provider = new ManagementTokenProvider(config); + it('should set cacheTTLInSeconds to 15 when passed as 15', () => { + const options = Object.assign({}, defaultOptions); + options.cacheTTLInSeconds = 15; + const provider = new ManagementTokenProvider(options); expect(provider.options.cacheTTLInSeconds).to.be.equal(15); }); - it('should handle network errors correctly', function(done) { - var config = assign({}, defaultConfig); - config.domain = 'domain'; - var client = new ManagementTokenProvider(config); + it('should set headers when passed into options', () => { + const options = Object.assign({}, defaultOptions); + options.headers = { + 'User-Agent': 'node.js', + 'Content-Type': 'application/json', + }; + const provider = new ManagementTokenProvider(options); + expect(provider.options.headers).to.be.equal(options.headers); + }); - nock('https://' + config.domain) - .post('/oauth/token') - .reply(401); + it('should handle network errors correctly', async () => { + const options = Object.assign({}, defaultOptions); + options.domain = 'domain'; + const client = new ManagementTokenProvider(options); - client.getAccessToken().catch(function(err) { + nock(`https://${options.domain}`).post('/oauth/token').reply(401); + + try { + await client.getAccessToken(); + } catch (err) { expect(err).to.exist; - done(); - }); + nock.cleanAll(); + } }); - it('should handle unauthorized errors correctly', function(done) { - var client = new ManagementTokenProvider(defaultConfig); - nock('https://' + defaultConfig.domain) - .post('/oauth/token') - .reply(401); + it('should handle unauthorized errors correctly', async () => { + const client = new ManagementTokenProvider(defaultOptions); + nock(`https://${defaultOptions.domain}`).post('/oauth/token').reply(401); - client.getAccessToken().catch(function(err) { - expect(err).to.exist.to.be.an.instanceOf(APIError); + try { + await client.getAccessToken(); + } catch (err) { + expect(err).to.exist.to.be.an.instanceOf(SanitizedError); expect(err.statusCode).to.be.equal(401); - done(); nock.cleanAll(); - }); + } }); - it('should return access token', function(done) { - var config = assign({}, defaultConfig); - config.domain = 'auth0-node-sdk-1.auth0.com'; - var client = new ManagementTokenProvider(config); + it('should expire access token from cache by the expires_in setting', async () => { + const clock = sinon.useFakeTimers({ toFake: ['Date'] }); + const options = Object.assign({}, defaultOptions); + options.domain = 'auth0-node-sdk-1.auth0.com'; + const client = new ManagementTokenProvider(options); - nock('https://' + config.domain) - .post('/oauth/token') - .reply(200, { - access_token: 'token', - expires_in: 3600 - }); + nock(`https://${options.domain}`).post('/oauth/token').reply(200, { + access_token: 'token', + expires_in: 10, + }); - client.getAccessToken().then(function(access_token) { - expect(access_token).to.exist; - expect(access_token).to.be.equal('token'); - done(); - nock.cleanAll(); + const accessToken = await client.getAccessToken(); + expect(accessToken).to.exist; + expect(accessToken).to.be.equal('token'); + await clock.tickAsync(10000 + 1); // + 1 ms so that the first mocked request can expire + + nock(`https://${options.domain}`).post('/oauth/token').reply(200, { + access_token: 'token2', + expires_in: 10, }); + const accessToken2 = await client.getAccessToken(); + expect(accessToken2).to.exist; + expect(accessToken2).to.be.equal('token2'); + + nock.cleanAll(); + clock.restore(); }); - it('should contain correct body payload', function(done) { - var config = assign({}, defaultConfig); - config.domain = 'auth0-node-sdk-2.auth0.com'; - var client = new ManagementTokenProvider(config); + it('should return access token', async () => { + const options = Object.assign({}, defaultOptions); + options.domain = 'auth0-node-sdk-1.auth0.com'; + const client = new ManagementTokenProvider(options); + + nock(`https://${options.domain}`).post('/oauth/token').reply(200, { + access_token: 'token', + expires_in: 3600, + }); - nock('https://' + config.domain) - .post('/oauth/token', function(body) { + const accessToken = await client.getAccessToken(); + expect(accessToken).to.exist; + expect(accessToken).to.be.equal('token'); + }); + + it('should contain correct body payload', (done) => { + const options = Object.assign({}, defaultOptions); + options.domain = 'auth0-node-sdk-2.auth0.com'; + const client = new ManagementTokenProvider(options); + + nock(`https://${options.domain}`) + .post('/oauth/token', (body) => { expect(body.client_id).to.equal('clientId'); expect(body.client_secret).to.equal('clientSecret'); expect(body.grant_type).to.equal('client_credentials'); + nock.cleanAll(); + done(); return true; }) - .reply(function(uri, requestBody, cb) { - return cb(null, [200, { access_token: 'token', expires_in: 3600 }]); - }); + .reply((uri, requestBody, cb) => + cb(null, [200, { access_token: 'token', expires_in: 3600 }]) + ); - client.getAccessToken().then(function(data) { - done(); - nock.cleanAll(); - }); + client.getAccessToken(); }); - it('should return access token from the cache the second call', function(done) { - var config = assign({}, defaultConfig); - config.domain = 'auth0-node-sdk-3.auth0.com'; - var client = new ManagementTokenProvider(config); + it('should return access token from the cache the second call', async () => { + const options = Object.assign({}, defaultOptions); + options.domain = 'auth0-node-sdk-3.auth0.com'; + const client = new ManagementTokenProvider(options); - nock('https://' + config.domain) - .post('/oauth/token') - .once() - .reply(200, { - access_token: 'access_token', - expires_in: 3600 - }); + nock(`https://${options.domain}`).post('/oauth/token').once().reply(200, { + access_token: 'access_token', + expires_in: 3600, + }); - client.getAccessToken().then(function(access_token) { - expect(access_token).to.exist; - expect(access_token).to.be.equal('access_token'); + const clock = sinon.useFakeTimers({ toFake: ['Date'] }); + const accessToken = await client.getAccessToken(); + expect(accessToken).to.exist; + expect(accessToken).to.be.equal('access_token'); - setTimeout(function() { - client - .getAccessToken() - .then(function(access_token) { - expect(access_token).to.exist; - expect(access_token).to.be.equal('access_token'); - done(); - nock.cleanAll(); - }) - .catch(function(err) { - expect.fail(); - done(); - nock.cleanAll(); - }); - }, 40); // 40ms - }); + clock.tick(40); + + const accessToken2 = await client.getAccessToken(); + await clock.runAllAsync(); + expect(accessToken2).to.exist; + expect(accessToken2).to.be.equal('access_token'); + nock.cleanAll(); + clock.restore(); }); - it('should request new access token when cache is expired', function(done) { - var config = assign({}, defaultConfig); - config.domain = 'auth0-node-sdk-4.auth0.com'; - var client = new ManagementTokenProvider(config); + it('should request new access token when cache is expired', (done) => { + const options = Object.assign({}, defaultOptions); + options.domain = 'auth0-node-sdk-4.auth0.com'; + const client = new ManagementTokenProvider(options); - nock('https://' + config.domain) + nock(`https://${options.domain}`) .post('/oauth/token') .reply(200, { access_token: 'access_token', - expires_in: 1 / 40 // 1sec / 40 = 25ms + expires_in: 1 / 40, // 1sec / 40 = 25ms }) .post('/oauth/token') .reply(200, { access_token: 'new_access_token', - expires_in: 3600 + expires_in: 3600, }); - client.getAccessToken().then(function(access_token) { + client.getAccessToken().then((access_token) => { expect(access_token).to.exist; expect(access_token).to.be.equal('access_token'); - setTimeout(function() { + setTimeout(() => { client .getAccessToken() - .then(function(access_token) { + .then((access_token) => { expect(access_token).to.exist; expect(access_token).to.be.equal('new_access_token'); done(); nock.cleanAll(); }) - .catch(function(err) { + .catch(() => { expect.fail(); done(); nock.cleanAll(); }); - }, 40); // 40ms + }, 40); }); }); - it('should return new access token on the second call when cache is disabled', function(done) { - var config = assign({}, defaultConfig); - config.enableCache = false; - config.domain = 'auth0-node-sdk-3.auth0.com'; - var client = new ManagementTokenProvider(config); + it('should return new access token on the second call when cache is disabled', (done) => { + const options = Object.assign({}, defaultOptions); + options.enableCache = false; + options.domain = 'auth0-node-sdk-3.auth0.com'; + const client = new ManagementTokenProvider(options); - nock('https://' + config.domain) + nock(`https://${options.domain}`) .post('/oauth/token') .reply(200, { access_token: 'access_token', - expires_in: 3600 + expires_in: 3600, }) .post('/oauth/token') .reply(200, { access_token: 'new_access_token', - expires_in: 3600 + expires_in: 3600, }); - client.getAccessToken().then(function(access_token) { + client.getAccessToken().then((access_token) => { expect(access_token).to.exist; expect(access_token).to.be.equal('access_token'); - setTimeout(function() { + setTimeout(() => { client .getAccessToken() - .then(function(access_token) { + .then((access_token) => { expect(access_token).to.exist; expect(access_token).to.be.equal('new_access_token'); done(); nock.cleanAll(); }) - .catch(function(err) { + .catch(() => { expect.fail(); done(); nock.cleanAll(); }); - }, 40); // 40ms + }, 40); }); }); - it('should return cached access token on the second call when cacheTTLInSeconds is not passed', function(done) { - var config = assign({}, defaultConfig); - config.domain = 'auth0-node-sdk-5.auth0.com'; - config.cacheTTLInSeconds = 10; // 1sec / 40 = 25ms; - var client = new ManagementTokenProvider(config); + it('should return cached access token on the second call when cacheTTLInSeconds is not passed', (done) => { + const options = Object.assign({}, defaultOptions); + options.domain = 'auth0-node-sdk-5.auth0.com'; + options.cacheTTLInSeconds = 10; // 1sec / 40 = 25ms; + const client = new ManagementTokenProvider(options); - nock('https://' + config.domain) + nock(`https://${options.domain}`) .post('/oauth/token') .reply(200, { - access_token: 'access_token' + access_token: 'access_token', }) .post('/oauth/token') .reply(200, { - access_token: 'new_access_token' + access_token: 'new_access_token', }); - client.getAccessToken().then(function(access_token) { + client.getAccessToken().then((access_token) => { expect(access_token).to.exist; expect(access_token).to.be.equal('access_token'); - setTimeout(function() { + setTimeout(() => { client .getAccessToken() - .then(function(access_token) { + .then((access_token) => { expect(access_token).to.exist; expect(access_token).to.be.equal('access_token'); done(); nock.cleanAll(); }) - .catch(function(err) { + .catch(() => { expect.fail(); done(); nock.cleanAll(); }); - }, 40); // 40ms + }, 40); }); }); - it('should return new access token on the second call when cacheTTLInSeconds is passed', function(done) { - var config = assign({}, defaultConfig); - config.domain = 'auth0-node-sdk-6.auth0.com'; - config.cacheTTLInSeconds = 1 / 40; // 1sec / 40 = 25ms - var client = new ManagementTokenProvider(config); + it('should return new access token on the second call when cacheTTLInSeconds is passed', (done) => { + const options = Object.assign({}, defaultOptions); + options.domain = 'auth0-node-sdk-6.auth0.com'; + options.cacheTTLInSeconds = 1 / 40; // 1sec / 40 = 25ms + const client = new ManagementTokenProvider(options); - nock('https://' + config.domain) + nock(`https://${options.domain}`) .post('/oauth/token') .reply(200, { - access_token: 'access_token' + access_token: 'access_token', }) .post('/oauth/token') .reply(200, { - access_token: 'new_access_token' + access_token: 'new_access_token', }); - client.getAccessToken().then(function(access_token) { + client.getAccessToken().then((access_token) => { expect(access_token).to.exist; expect(access_token).to.be.equal('access_token'); - setTimeout(function() { + setTimeout(() => { client .getAccessToken() - .then(function(access_token) { + .then((access_token) => { expect(access_token).to.exist; expect(access_token).to.be.equal('new_access_token'); done(); nock.cleanAll(); }) - .catch(function(err) { + .catch(() => { expect.fail(); done(); nock.cleanAll(); }); - }, 40); // 40ms + }, 40); }); }); - it('should pass the correct payload in the body of the oauth/token request with cache enabled', function(done) { - var config = assign({}, defaultConfig); - var client = new ManagementTokenProvider(config); + it('should pass the correct payload in the body of the oauth/token request with cache enabled', (done) => { + const options = Object.assign({}, defaultOptions); + const client = new ManagementTokenProvider(options); - nock('https://' + config.domain) - .post('/oauth/token', function(payload) { + nock(`https://${options.domain}`) + .post('/oauth/token', (payload) => { expect(payload).to.exist; expect(payload.client_id).to.be.equal('clientId'); expect(payload.client_secret).to.be.equal('clientSecret'); @@ -414,19 +440,19 @@ describe('ManagementTokenProvider', function() { }) .reply(200); - client.getAccessToken().then(function(access_token) { + client.getAccessToken().then(() => { done(); nock.cleanAll(); }); }); - it('should pass the correct payload in the body of the oauth/token request with cache disabled', function(done) { - var config = assign({}, defaultConfig); - config.enableCache = false; - var client = new ManagementTokenProvider(config); + it('should pass the correct payload in the body of the oauth/token request with cache disabled', (done) => { + const options = Object.assign({}, defaultOptions); + options.enableCache = false; + const client = new ManagementTokenProvider(options); - nock('https://' + config.domain) - .post('/oauth/token', function(payload) { + nock(`https://${options.domain}`) + .post('/oauth/token', (payload) => { expect(payload).to.exist; expect(payload.client_id).to.be.equal('clientId'); expect(payload.client_secret).to.be.equal('clientSecret'); @@ -435,7 +461,7 @@ describe('ManagementTokenProvider', function() { }) .reply(200); - client.getAccessToken().then(function(access_token) { + client.getAccessToken().then(() => { done(); nock.cleanAll(); }); diff --git a/test/management/migrations.tests.js b/test/management/migrations.tests.js new file mode 100644 index 000000000..7563eb351 --- /dev/null +++ b/test/management/migrations.tests.js @@ -0,0 +1,214 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenants.auth0.com'; + +const MigrationsManager = require(`../../src/management/MigrationsManager`); +const { ArgumentError } = require('rest-facade'); + +describe('MigrationsManager', () => { + before(function () { + this.token = 'TOKEN'; + this.migrations = new MigrationsManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = ['updateMigrations', 'getMigrations']; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.migrations[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new MigrationsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new MigrationsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new MigrationsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#getMigrations', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/migrations').reply(200); + }); + + it('should accept a callback', function (done) { + this.migrations.getMigrations(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.migrations.getMigrations().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/migrations').reply(500); + + this.migrations.getMigrations().catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const data = { flags: { migration_flag: true } }; + nock(API_URL).get('/migrations').reply(200, data); + + this.migrations.getMigrations().then((migrations) => { + expect(migrations).to.be.an('object'); + + expect(migrations).to.have.nested.property('flags.migration_flag', true); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/migrations', function (done) { + const { request } = this; + + this.migrations.getMigrations().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/migrations') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.migrations.getMigrations().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/migrations') + .query({ + any: 'test', + }) + .reply(200); + + this.migrations.getMigrations({ any: 'test' }).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + }); + + describe('#updateMigrations', () => { + const data = { + flags: { + migration: false, + }, + }; + + beforeEach(function () { + this.request = nock(API_URL).patch('/migrations').reply(200); + }); + + it('should accept a callback', function (done) { + this.migrations.updateMigrations(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.migrations + .updateMigrations(data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch('/migrations').reply(500); + + this.migrations.updateMigrations(data).catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should perform a PATCH request to /api/v2migrations', function (done) { + const { request } = this; + + this.migrations.updateMigrations(data).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).patch('/migrations', data).reply(200); + + this.migrations.updateMigrations(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + const result = { flags: { migration_flag: true } }; + nock(API_URL).patch('/migrations').reply(200, result); + + this.migrations.updateMigrations(data).then((migrations) => { + expect(migrations).to.be.an('object'); + + expect(migrations).to.have.nested.property('flags.migration_flag', true); + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch('/migrations') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.migrations.updateMigrations(data).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + }); +}); diff --git a/test/management/organizations.tests.js b/test/management/organizations.tests.js new file mode 100644 index 000000000..d811c1c95 --- /dev/null +++ b/test/management/organizations.tests.js @@ -0,0 +1,1650 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenant.auth0.com'; + +const OrganizationsManager = require(`../../src/management/OrganizationsManager`); +const { ArgumentError } = require('rest-facade'); + +describe('OrganizationsManager', () => { + /** + * @type {OrganizationsManager} + */ + let organizations; + + /** + * @type {string} + */ + let token; + + before(() => { + token = 'TOKEN'; + organizations = new OrganizationsManager({ + headers: { authorization: `Bearer ${token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = [ + 'getByID', + 'getByName', + 'getAll', + 'create', + 'update', + 'delete', + 'getEnabledConnections', + 'getEnabledConnection', + 'addEnabledConnection', + 'updateEnabledConnection', + 'removeEnabledConnection', + 'getMembers', + 'addMembers', + 'removeMembers', + 'getMemberRoles', + 'addMemberRoles', + 'removeMemberRoles', + 'getInvitations', + 'getInvitation', + 'createInvitation', + 'deleteInvitation', + ]; + + methods.forEach((method) => { + it(`should have a ${method} method`, () => { + expect(organizations[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new OrganizationsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new OrganizationsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new OrganizationsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/organizations').reply(200); + }); + + it('should accept a callback', (done) => { + organizations.getAll(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', (done) => { + organizations.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).get('/organizations').reply(500); + + organizations.getAll().catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', (done) => { + nock.cleanAll(); + + const data = [{ test: true }]; + nock(API_URL).get('/organizations').reply(200, data); + + organizations.getAll().then((credentials) => { + expect(credentials).to.be.an.instanceOf(Array); + + expect(credentials.length).to.equal(data.length); + + expect(credentials[0].test).to.equal(data[0].test); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/organizations', function (done) { + const { request } = this; + + organizations.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/organizations') + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.getAll().then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should pass the parameters in the query-string', (done) => { + nock.cleanAll(); + + const params = { + include_fields: true, + fields: 'test', + }; + const request = nock(API_URL).get('/organizations').query(params).reply(200); + + organizations.getAll(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getByID', () => { + beforeEach(function () { + this.data = { + id: 'org_123456', + name: 'organizations', + display_name: 'My organization', + }; + + this.request = nock(API_URL).get(`/organizations/${this.data.id}`).reply(200, this.data); + }); + + it('should accept a callback', function (done) { + const params = { id: this.data.id }; + + organizations.getByID(params, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .getByID({ id: this.data.id }) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/organizations/:id', function (done) { + const { request } = this; + + organizations.getByID({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/organizations/${this.data.id}`).reply(500); + + organizations.getByID({ id: this.data.id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/organizations/${this.data.id}`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.getByID({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getByName', () => { + beforeEach(function () { + this.data = { + id: 'org_123456', + name: 'organizations', + display_name: 'My organization', + }; + + this.request = nock(API_URL) + .get(`/organizations/name/${this.data.name}`) + .reply(200, this.data); + }); + + it('should accept a callback', function (done) { + const params = { name: this.data.name }; + + organizations.getByName(params, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .getByName({ name: this.data.name }) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/organizations/name/:name', function (done) { + const { request } = this; + + organizations.getByName({ name: this.data.name }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/organizations/${this.data.name}`).reply(500); + + organizations.getByName({ name: this.data.name }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/organizations/name/${this.data.name}`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.getByName({ name: this.data.name }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#create', () => { + const data = { + id: 'org_123', + name: 'org_name', + display_name: 'My Organization', + }; + + beforeEach(function () { + this.request = nock(API_URL).post('/organizations').reply(200); + }); + + it('should accept a callback', (done) => { + organizations.create(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', (done) => { + organizations.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).post('/organizations').reply(500); + + organizations.create(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/organizations', function (done) { + const { request } = this; + + organizations.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', (done) => { + nock.cleanAll(); + + const request = nock(API_URL).post('/organizations', data).reply(200); + + organizations.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .post('/organizations') + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#update', () => { + beforeEach(function () { + this.data = { id: 'org_123' }; + + this.request = nock(API_URL).patch(`/organizations/${this.data.id}`).reply(200, this.data); + }); + + it('should accept a callback', (done) => { + organizations.update({ id: 'org_123' }, {}, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', (done) => { + organizations + .update({ id: 'org_123' }, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PATCH request to /api/v2/organizations/org_123', function (done) { + const { request } = this; + + organizations.update({ id: 'org_123' }, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).patch(`/organizations/${this.data.id}`, this.data).reply(200); + + organizations.update({ id: 'org_123' }, this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/organizations/${this.data.id}`).reply(500); + + organizations.update({ id: this.data.id }, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + }); + + describe('#delete', () => { + const id = 'rol_ID'; + + beforeEach(function () { + this.request = nock(API_URL).delete(`/organizations/${id}`).reply(200); + }); + + it('should accept a callback', (done) => { + organizations.delete({ id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', (done) => { + organizations.delete({ id }).then(done.bind(null, null)); + }); + + it(`should perform a delete request to /organizations/${id}`, function (done) { + const { request } = this; + + organizations.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).delete(`/organizations/${id}`).reply(500); + + organizations.delete({ id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/organizations/${id}`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + organizations.delete({ id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + //// Connections + describe('#getEnabledConnections', () => { + const data = { + id: 'org_id', + }; + + beforeEach(function () { + this.request = nock(API_URL).get(`/organizations/${data.id}/enabled_connections`).reply(200); + }); + + it('should accept a callback', (done) => { + organizations.getEnabledConnections(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', (done) => { + organizations.getEnabledConnections(data).then(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/organizations/org_id/enabled_connections', function (done) { + const { request } = this; + + organizations.getEnabledConnections(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).get(`/organizations/${data.id}/enabled_connections`).reply(500); + + organizations.getEnabledConnections(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/organizations/${data.id}/enabled_connections`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + organizations.getEnabledConnections(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getEnabledConnection', () => { + const data = { + id: 'org_id', + connection_id: 'conn_id', + }; + + beforeEach(function () { + this.request = nock(API_URL) + .get(`/organizations/${data.id}/enabled_connections/${data.connection_id}`) + .reply(200); + }); + + it('should accept a callback', (done) => { + organizations.getEnabledConnection(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', (done) => { + organizations.getEnabledConnection(data).then(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/organizations/rol_ID/enabled_connections/con_id', function (done) { + const { request } = this; + + organizations.getEnabledConnection(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL) + .get(`/organizations/${data.id}/enabled_connections/${data.connection_id}`) + .reply(500); + + organizations.getEnabledConnection(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/organizations/${data.id}/enabled_connections/${data.connection_id}`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + organizations.getEnabledConnection(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#addEnabledConnection', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + }; + this.body = { connection_id: '123', assign_membership_on_login: false }; + + this.request = nock(API_URL) + .post(`/organizations/${this.data.id}/enabled_connections`) + .reply(200); + }); + + it('should accept a callback', function (done) { + organizations.addEnabledConnection(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .addEnabledConnection(this.data, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/organizations/${this.data.id}/enabled_connections`).reply(500); + + organizations.addEnabledConnection(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/organizations/org_id/enabled_connections', function (done) { + const { request } = this; + + organizations.addEnabledConnection(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.addEnabledConnection({ id: null }, {}, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not a string', () => { + expect(() => { + organizations.addEnabledConnection({ id: 123 }, {}, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/organizations/${this.data.id}/enabled_connections`, this.body) + .reply(200); + + organizations.addEnabledConnection(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/organizations/${this.data.id}/enabled_connections`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.addEnabledConnection(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateEnabledConnection', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + connection_id: '123', + }; + this.body = { assign_membership_on_login: false }; + + this.request = nock(API_URL) + .patch(`/organizations/${this.data.id}/enabled_connections/${this.data.connection_id}`) + .reply(200); + }); + + it('should accept a callback', function (done) { + organizations.updateEnabledConnection(this.data, this.body, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .updateEnabledConnection(this.data, this.body) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL) + .patch(`/organizations/${this.data.id}/enabled_connections/${this.data.connection_id}`) + .reply(500); + + organizations.updateEnabledConnection(this.data, this.body).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a PATCH request to /api/v2/organizations/org_id/enabled_connections/conn_id', function (done) { + const { request } = this; + + organizations.updateEnabledConnection(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.updateEnabledConnection({ id: null }, {}, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not a string', () => { + expect(() => { + organizations.updateEnabledConnection({ id: 123 }, {}, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should return error when connection_id is not sent', () => { + expect(() => { + organizations.updateEnabledConnection({ id: 'org_123', connection_id: null }, {}, () => {}); + }).to.throw('The connection ID passed in params cannot be null or undefined'); + }); + + it('should return error when connection_id is not a string', () => { + expect(() => { + organizations.updateEnabledConnection({ id: 'org_123', connection_id: 123 }, {}, () => {}); + }).to.throw('The connection ID has to be a string'); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch( + `/organizations/${this.data.id}/enabled_connections/${this.data.connection_id}`, + this.body + ) + .reply(200); + + organizations.updateEnabledConnection(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch(`/organizations/${this.data.id}/enabled_connections/${this.data.connection_id}`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.updateEnabledConnection(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#removeEnabledConnection', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + connection_id: '123', + }; + + this.request = nock(API_URL) + .delete(`/organizations/${this.data.id}/enabled_connections/${this.data.connection_id}`, {}) + .reply(200); + }); + + it('should validate empty organizationId', () => { + expect(() => { + organizations.removeEnabledConnection({ id: null }, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should validate empty connectionId', function () { + const _this = this; + expect(() => { + organizations.removeEnabledConnection({ id: _this.data.id }, () => {}); + }).to.throw('The connection ID passed in params cannot be null or undefined'); + }); + + it('should validate non-string organizationId', () => { + expect(() => { + organizations.removeEnabledConnection({ id: 123 }, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should validate non-string connectionId', function () { + const _this = this; + expect(() => { + organizations.removeEnabledConnection({ id: _this.data.id, connection_id: 123 }, () => {}); + }).to.throw('The connection ID has to be a string'); + }); + + it('should accept a callback', function (done) { + organizations.removeEnabledConnection(this.data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .removeEnabledConnection(this.data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL) + .delete(`/organizations/${this.data.id}/enabled_connections/${this.data.connection_id}`) + .reply(500); + + organizations.removeEnabledConnection(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a DELETE request to /api/v2/organizations/organization_id/enabled_connections/connection_id', function (done) { + const { request } = this; + + organizations.removeEnabledConnection(this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/organizations/${this.data.id}/enabled_connections/${this.data.connection_id}`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.removeEnabledConnection(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + //// Members + describe('#getMembers', () => { + const data = { + id: 'org_id', + }; + + beforeEach(function () { + this.request = nock(API_URL).get(`/organizations/${data.id}/members`).reply(200); + }); + + it('should accept a callback', (done) => { + organizations.getMembers(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', (done) => { + organizations.getMembers(data).then(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/organizations/org_ID/members', function (done) { + const { request } = this; + + organizations.getMembers(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).get(`/organizations/${data.id}/members`).reply(500); + + organizations.getMembers(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/organizations/${data.id}/members`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + organizations.getMembers(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#addMembers', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + }; + this.body = ['user_id']; + + this.request = nock(API_URL).post(`/organizations/${this.data.id}/members`, {}).reply(200); + }); + + it('should accept a callback', function (done) { + organizations.addMembers(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .addMembers(this.data, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/organizations/${this.data.id}/members`).reply(500); + + organizations.addMembers(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/organizations/org_id/members', function (done) { + const { request } = this; + + organizations.addMembers(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.addMembers({ id: null }, {}, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.addMembers({ id: 123 }, {}, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/organizations/${this.data.id}/members`, this.body) + .reply(200); + + organizations.addMembers(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/organizations/${this.data.id}/members`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.addMembers(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#removeMembers', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + }; + + this.body = ['user_id']; + + this.request = nock(API_URL).delete(`/organizations/${this.data.id}/members`, {}).reply(200); + }); + + it('should validate empty organizationId', () => { + expect(function () { + organizations.removeMembers({ id: null }, this.body, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should validate non-string organizationId', function () { + const _this = this; + expect(() => { + organizations.removeMembers({ id: 123 }, _this.body, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .removeMembers(this.data, this.body) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete(`/organizations/${this.data.id}/members`).reply(500); + + organizations.removeMembers(this.data, this.body).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a DELETE request to /api/v2/organizations/organization_id/members', function (done) { + const request = nock(API_URL) + .delete(`/organizations/${this.data.id}/members`, this.body) + .reply(200); + + organizations.removeMembers(this.data, this.body, () => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/organizations/${this.data.id}/members`, this.body) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.removeMembers(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + //// Roles + describe('#getMemberRoles', () => { + const data = { + id: 'org_id', + user_id: 'user_123', + }; + + beforeEach(function () { + this.request = nock(API_URL) + .get(`/organizations/${data.id}/members/${data.user_id}/roles`) + .reply(200); + }); + + it('should accept a callback', (done) => { + organizations.getMemberRoles(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', (done) => { + organizations.getMemberRoles(data).then(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/organizations/org_ID/members/user_id/roles', function (done) { + const { request } = this; + + organizations.getMemberRoles(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).get(`/organizations/${data.id}/members/${data.user_id}/roles`).reply(500); + + organizations.getMemberRoles(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/organizations/${data.id}/members/${data.user_id}/roles`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + organizations.getMemberRoles(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#addMemberRoles', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + user_id: 'user_id', + }; + this.body = { roles: ['user_id'] }; + + this.request = nock(API_URL) + .post(`/organizations/${this.data.id}/members/${this.data.user_id}/roles`, this.body) + .reply(200); + }); + + it('should accept a callback', function (done) { + organizations.addMemberRoles(this.data, this.body, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .addMemberRoles(this.data, this.body) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL) + .post(`/organizations/${this.data.id}/members/${this.data.user_id}/roles`) + .reply(500); + + organizations.addMemberRoles(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/organizations/org_id/members/user_id/roles', function (done) { + const { request } = this; + + organizations.addMemberRoles(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.addMemberRoles({ id: null }, {}, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.addMemberRoles({ id: 123 }, {}, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.addMemberRoles({ id: 'org_123', user_id: null }, {}, () => {}); + }).to.throw('The user ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.addMemberRoles({ id: 'org_123', user_id: 123 }, {}, () => {}); + }).to.throw('The user ID has to be a string'); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/organizations/${this.data.id}/members/${this.data.user_id}/roles`, this.body) + .reply(200); + + organizations.addMemberRoles(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/organizations/${this.data.id}/members/${this.data.user_id}/roles`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.addMemberRoles(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#removeMemberRoles', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + user_id: 'user_123', + }; + + this.body = { roles: ['user_id'] }; + + this.request = nock(API_URL) + .delete(`/organizations/${this.data.id}/members/${this.data.user_id}/roles`, {}) + .reply(200); + }); + + it('should validate empty organizationId', () => { + expect(function () { + organizations.removeMemberRoles({ id: null }, this.body, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should validate non-string organizationId', function () { + const _this = this; + expect(() => { + organizations.removeMemberRoles({ id: 123 }, _this.body, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .removeMemberRoles(this.data, this.body) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL) + .delete(`/organizations/${this.data.id}/members/${this.data.user_id}/roles`) + .reply(500); + + organizations.removeMemberRoles(this.data, this.body).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.removeMemberRoles({ id: 'org_123', user_id: null }, {}, () => {}); + }).to.throw('The user ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.removeMemberRoles({ id: 'org_123', user_id: 123 }, {}, () => {}); + }).to.throw('The user ID has to be a string'); + }); + + it('should perform a DELETE request to /api/v2/organizations/organization_id/members/user_id/roles', function (done) { + const request = nock(API_URL) + .delete(`/organizations/${this.data.id}/members/${this.data.user_id}/roles`, this.body) + .reply(200); + + organizations.removeMemberRoles(this.data, this.body, () => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/organizations/${this.data.id}/members/${this.data.user_id}/roles`, this.body) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.removeMemberRoles(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + //// Invites + describe('#getInvitations', () => { + const data = { + id: 'org_id', + }; + + beforeEach(function () { + this.request = nock(API_URL).get(`/organizations/${data.id}/invitations`).reply(200); + }); + + it('should accept a callback', (done) => { + organizations.getInvitations(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', (done) => { + organizations.getInvitations(data).then(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/organizations/org_ID/invitations', function (done) { + const { request } = this; + + organizations.getInvitations(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).get(`/organizations/${data.id}/invitations`).reply(500); + + organizations.getInvitations(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/organizations/${data.id}/invitations`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + organizations.getInvitations(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getInvitation', () => { + const data = { + id: 'org_id', + invitation_id: 'inv_123', + }; + + beforeEach(function () { + this.request = nock(API_URL) + .get(`/organizations/${data.id}/invitations/${data.invitation_id}`) + .reply(200); + }); + + it('should accept a callback', (done) => { + organizations.getInvitation(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', (done) => { + organizations.getInvitation(data).then(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/organizations/rol_ID/invitations/inv_id', function (done) { + const { request } = this; + + organizations.getInvitation(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).get(`/organizations/${data.id}/invitations/${data.invitation_id}`).reply(500); + + organizations.getInvitation(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.getInvitation({ id: null }, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.getInvitation({ id: 123 }, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.getInvitation({ id: 'org_123', invitation_id: null }, () => {}); + }).to.throw('The invitation ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.getInvitation({ id: 'org_123', invitation_id: 123 }, () => {}); + }).to.throw('The invitation ID has to be a string'); + }); + + it('should include the token in the authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/organizations/${data.id}/invitations/${data.invitation_id}`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + organizations.getInvitation(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#createInvitation', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + }; + this.body = { + invitee: 'inv', + client_id: 'cid', + }; + + this.request = nock(API_URL) + .post(`/organizations/${this.data.id}/invitations`, {}) + .reply(200); + }); + + it('should accept a callback', function (done) { + organizations.createInvitation(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .createInvitation(this.data, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/organizations/${this.data.id}/invitations`).reply(500); + + organizations.createInvitation(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/organizations/org_id/invitations', function (done) { + const { request } = this; + + organizations.createInvitation(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.createInvitation({ id: null }, {}, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.createInvitation({ id: 123 }, {}, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/organizations/${this.data.id}/invitations`, this.body) + .reply(200); + + organizations.createInvitation(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/organizations/${this.data.id}/invitations`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.createInvitation(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#deleteInvitation', () => { + beforeEach(function () { + this.data = { + id: 'org_123', + invitation_id: 'inv_123', + }; + + this.request = nock(API_URL) + .delete(`/organizations/${this.data.id}/invitations/${this.data.invitation_id}`, {}) + .reply(200); + }); + + it('should validate empty organizationId', () => { + expect(() => { + organizations.deleteInvitation({ id: null }, () => {}); + }).to.throw('The organization ID passed in params cannot be null or undefined'); + }); + + it('should validate non-string organizationId', () => { + expect(() => { + organizations.deleteInvitation({ id: 123 }, () => {}); + }).to.throw('The organization ID has to be a string'); + }); + + it('should return a promise if no callback is given', function (done) { + organizations + .removeMembers(this.data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL) + .delete(`/organizations/${this.data.id}/invitations/${this.data.invitation_id}`, {}) + .reply(500); + + organizations.deleteInvitation(this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a DELETE request to /api/v2/organizations/organization_id/invitations/inv_id', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/organizations/${this.data.id}/invitations/${this.data.invitation_id}`, {}) + .reply(200); + + organizations.deleteInvitation(this.data, () => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.deleteInvitation({ id: 'org_123', invitation_id: null }, () => {}); + }).to.throw('The invitation ID passed in params cannot be null or undefined'); + }); + + it('should return error when id is not sent', () => { + expect(() => { + organizations.deleteInvitation({ id: 'org_123', invitation_id: 123 }, () => {}); + }).to.throw('The invitation ID has to be a string'); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/organizations/${this.data.id}/invitations/${this.data.invitation_id}`, {}) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + organizations.deleteInvitation(this.data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); +}); diff --git a/test/management/prompts.tests.js b/test/management/prompts.tests.js new file mode 100644 index 000000000..b1bd439d2 --- /dev/null +++ b/test/management/prompts.tests.js @@ -0,0 +1,387 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenant.auth0.com'; + +const PromptsManager = require(`../../src/management/PromptsManager`); +const { ArgumentError } = require('rest-facade'); + +describe('PromptsManager', () => { + before(function () { + this.token = 'TOKEN'; + this.prompts = new PromptsManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = ['getSettings', 'updateSettings']; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.prompts[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new PromptsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new PromptsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new PromptsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#getSettings', () => { + const data = { + universal_login_experience: '', + }; + + beforeEach(function () { + this.request = nock(API_URL).get('/prompts').reply(200); + }); + + it('should accept a callback', function (done) { + this.prompts.getSettings(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.prompts.getSettings().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/prompts').reply(500); + + this.prompts.getSettings().catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/prompts').reply(200, data); + + this.prompts.getSettings().then((provider) => { + expect(provider.id).to.equal(data.id); + + done(); + }); + }); + + it('should perform a GET request to /api/v2/prompts', function (done) { + const { request } = this; + + this.prompts.getSettings().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/prompts') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.prompts.getSettings().then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the parameters in the query-string', function (done) { + nock.cleanAll(); + + const params = { + include_fields: true, + fields: 'test', + }; + + const request = nock(API_URL).get('/prompts').query(params).reply(200); + + this.prompts.getSettings(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateSettings', () => { + const data = { + universal_login_experience: 'new', + }; + + beforeEach(function () { + this.request = nock(API_URL).patch('/prompts').reply(200, data); + }); + + it('should accept a callback', function (done) { + this.prompts.updateSettings({}, data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.prompts + .updateSettings({}, data) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/prompts/${data.id}`).reply(500); + + this.prompts.updateSettings({}, data).catch((err) => { + expect(err).to.exist.to.be.an.instanceOf(Error); + + done(); + }); + }); + + it('should perform a PATCH request to /api/v2/prompts', function (done) { + const { request } = this; + + this.prompts.updateSettings({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).patch('/prompts', data).reply(200); + + this.prompts.updateSettings({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .patch('/prompts') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.prompts.updateSettings({}, data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getCustomTextByLanguage', () => { + const params = { + prompt: 'test', + language: 'english', + }; + + beforeEach(function () { + this.request = nock(API_URL).get('/prompts/test/custom-text/english').reply(200); + }); + + it('should validate empty prompt parameter', function () { + const _this = this; + expect(() => { + _this.prompts.getCustomTextByLanguage({}, _this.body, () => {}); + }).to.throw('The prompt parameter must be a string'); + }); + + it('should validate empty language parameter', function () { + const _this = this; + expect(() => { + _this.prompts.getCustomTextByLanguage({ prompt: 'test' }, _this.body, () => {}); + }).to.throw('The language parameter must be a string'); + }); + + it('should accept a callback', function (done) { + this.prompts.getCustomTextByLanguage(params, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.prompts + .getCustomTextByLanguage(params) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/prompts/test/custom-text/english').reply(500); + + this.prompts.getCustomTextByLanguage(params).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a GET request to /api/v2/prompts/test/custom-text/english', function (done) { + const { request } = this; + + this.prompts.getCustomTextByLanguage(params).then(() => { + expect(request.isDone()).to.be.true; + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/prompts/test/custom-text/english') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.prompts.getCustomTextByLanguage(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#updateCustomTextByLanguage', () => { + const params = { + prompt: 'test', + language: 'english', + body: { login: { title: 'Hello!' } }, + }; + + beforeEach(function () { + this.request = nock(API_URL).put('/prompts/test/custom-text/english').reply(200); + }); + + it('should validate empty prompt parameter', function () { + const _this = this; + expect(() => { + _this.prompts.updateCustomTextByLanguage({}, _this.body, () => {}); + }).to.throw('The prompt parameter must be a string'); + }); + + it('should validate empty language parameter', function () { + const _this = this; + expect(() => { + _this.prompts.updateCustomTextByLanguage({ prompt: 'test' }, _this.body, () => {}); + }).to.throw('The language parameter must be a string'); + }); + + it('should validate empty body parameter', function () { + const _this = this; + expect(() => { + _this.prompts.updateCustomTextByLanguage( + { prompt: 'test', language: 'english' }, + _this.body, + () => {} + ); + }).to.throw('The body parameter must be an object'); + }); + + it('should accept a callback', function (done) { + this.prompts.updateCustomTextByLanguage(params, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.prompts + .updateCustomTextByLanguage(params) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).put('/prompts/test/custom-text/english').reply(500); + + this.prompts.updateCustomTextByLanguage(params).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a PUT request to /api/v2/prompts/test/custom-text/english', function (done) { + const { request } = this; + + this.prompts + .updateCustomTextByLanguage(params) + .then(() => { + expect(request.isDone()).to.be.true; + done(); + }) + .catch((e) => { + console.error(e); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put('/prompts/test/custom-text/english') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.prompts.updateCustomTextByLanguage(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should send the payload to the body', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .put( + '/prompts/test/custom-text/english', + (body) => body && body.login && body.login.title === 'Hello!' + ) + .reply(200); + + this.prompts.updateCustomTextByLanguage(params).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); +}); diff --git a/test/management/resource-servers.tests.js b/test/management/resource-servers.tests.js index 829a35233..dc56ecc02 100644 --- a/test/management/resource-servers.tests.js +++ b/test/management/resource-servers.tests.js @@ -1,102 +1,90 @@ -var expect = require('chai').expect; -var nock = require('nock'); -var Promise = require('bluebird'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var ResourceServersManager = require(SRC_DIR + '/management/ResourceServersManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const ResourceServersManager = require(`../../src/management/ResourceServersManager`); +const { ArgumentError } = require('rest-facade'); -describe('ResourceServersManager', function() { - before(function() { +describe('ResourceServersManager', () => { + before(function () { this.token = 'TOKEN'; this.resourceServers = new ResourceServersManager({ headers: { - authorization: 'Bearer ' + this.token + authorization: `Bearer ${this.token}`, }, - baseUrl: API_URL + baseUrl: API_URL, }); }); - afterEach(function() { + afterEach(() => { nock.cleanAll(); }); - describe('instance', function() { - var methods = ['get', 'create', 'update', 'delete']; + describe('instance', () => { + const methods = ['get', 'create', 'update', 'delete']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.resourceServers[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(ResourceServersManager).to.throw( - ArgumentError, - 'Must provide resource server options' - ); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new ResourceServersManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var resourceServerManager = ResourceServersManager.bind(null, {}); - - expect(resourceServerManager).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new ResourceServersManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var resourceServerManager = ResourceServersManager.bind(null, { baseUrl: '' }); - - expect(resourceServerManager).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new ResourceServersManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/resource-servers') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/resource-servers').reply(200); }); - it('should accept a callback', function(done) { - this.resourceServers.getAll(function() { + it('should accept a callback', function (done) { + this.resourceServers.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.resourceServers - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.resourceServers.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/resource-servers') - .reply(500); + nock(API_URL).get('/resource-servers').reply(500); - this.resourceServers.getAll().catch(function(err) { + this.resourceServers.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/resource-servers') - .reply(200, data); + const data = [{ test: true }]; + nock(API_URL).get('/resource-servers').reply(200, data); - this.resourceServers.getAll().then(function(resourceServers) { + this.resourceServers.getAll().then((resourceServers) => { expect(resourceServers).to.be.an.instanceOf(Array); expect(resourceServers.length).to.equal(data.length); @@ -107,104 +95,95 @@ describe('ResourceServersManager', function() { }); }); - it('should perform a GET request to /api/v2/resource-servers', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/resource-servers', function (done) { + const { request } = this; - this.resourceServers.getAll().then(function() { + this.resourceServers.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/resource-servers') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.resourceServers.getAll().then(function() { + this.resourceServers.getAll().then(() => { expect(request.isDone()).to.be.true; done(); }); }); }); - describe('#get', function() { - var params = { id: 5 }; - var data = { + describe('#get', () => { + const params = { id: 5 }; + const data = { id: params.id, - name: 'Test Resource Server' + name: 'Test Resource Server', }; - beforeEach(function() { - this.request = nock(API_URL) - .get('/resource-servers/' + data.id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).get(`/resource-servers/${data.id}`).reply(200); }); - it('should accept a callback', function(done) { - this.resourceServers.get(params, function() { + it('should accept a callback', function (done) { + this.resourceServers.get(params, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.resourceServers - .get(params) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.resourceServers.get(params).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/resource-servers/' + params.id) - .reply(500); + nock(API_URL).get(`/resource-servers/${params.id}`).reply(500); - this.resourceServers.get().catch(function(err) { + this.resourceServers.get().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/resource-servers/' + params.id) - .reply(200, data); + nock(API_URL).get(`/resource-servers/${params.id}`).reply(200, data); - this.resourceServers.get(params).then(function(connection) { + this.resourceServers.get(params).then((connection) => { expect(connection.id).to.equal(data.id); done(); }); }); - it('should perform a GET request to /api/v2/resource-servers/:id', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/resource-servers/:id', function (done) { + const { request } = this; - this.resourceServers.get(params).then(function() { + this.resourceServers.get(params).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/resource-servers') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.resourceServers.get().then(function() { + this.resourceServers.get().then(() => { expect(request.isDone()).to.be.true; done(); @@ -212,78 +191,69 @@ describe('ResourceServersManager', function() { }); }); - describe('#create', function() { - var data = { + describe('#create', () => { + const data = { name: 'Acme Backend API', - options: {} + options: {}, }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/resource-servers') - .reply(200, data); + beforeEach(function () { + this.request = nock(API_URL).post('/resource-servers').reply(200, data); }); - it('should accept a callback', function(done) { - this.resourceServers.create(data, function() { + it('should accept a callback', function (done) { + this.resourceServers.create(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.resourceServers - .create(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.resourceServers.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/resource-servers') - .reply(500); + nock(API_URL).post('/resource-servers').reply(500); - this.resourceServers.create(data).catch(function(err) { + this.resourceServers.create(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/resource-servers', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2/resource-servers', function (done) { + const { request } = this; - this.resourceServers.create(data).then(function() { + this.resourceServers.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/resource-servers', data) - .reply(200); + const request = nock(API_URL).post('/resource-servers', data).reply(200); - this.resourceServers.create(data).then(function() { + this.resourceServers.create(data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/resource-servers') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.resourceServers.create(data).then(function() { + this.resourceServers.create(data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -291,80 +261,74 @@ describe('ResourceServersManager', function() { }); }); - describe('#update', function() { - var params = { id: 5 }; - var data = { + describe('#update', () => { + const params = { id: 5 }; + const data = { id: 5, name: 'Acme Backend API', - options: {} + options: {}, }; - beforeEach(function() { - this.request = nock(API_URL) - .patch('/resource-servers/' + data.id) - .reply(200, data); + beforeEach(function () { + this.request = nock(API_URL).patch(`/resource-servers/${data.id}`).reply(200, data); }); - it('should accept a callback', function(done) { - this.resourceServers.update(params, data, function() { + it('should accept a callback', function (done) { + this.resourceServers.update(params, data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { + it('should return a promise if no callback is given', function (done) { this.resourceServers .update(params, data) .then(done.bind(null, null)) .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/resource-servers/' + data.id) - .reply(500); + nock(API_URL).patch(`/resource-servers/${data.id}`).reply(500); - this.resourceServers.update(params, data).catch(function(err) { + this.resourceServers.update(params, data).catch((err) => { expect(err).to.exist.to.be.an.instanceOf(Error); done(); }); }); - it('should perform a PATCH request to /api/v2/resource-servers/:id', function(done) { - var request = this.request; + it('should perform a PATCH request to /api/v2/resource-servers/:id', function (done) { + const { request } = this; - this.resourceServers.update(params, data).then(function() { + this.resourceServers.update(params, data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/resource-servers/' + data.id, data) - .reply(200); + const request = nock(API_URL).patch(`/resource-servers/${data.id}`, data).reply(200); - this.resourceServers.update(params, data).then(function() { + this.resourceServers.update(params, data).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/resource-servers/' + data.id) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .patch(`/resource-servers/${data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.resourceServers.update(params, data).then(function() { + this.resourceServers.update(params, data).then(() => { expect(request.isDone()).to.be.true; done(); @@ -372,56 +336,52 @@ describe('ResourceServersManager', function() { }); }); - describe('#delete', function() { - var id = 5; + describe('#delete', () => { + const id = 5; - beforeEach(function() { - this.request = nock(API_URL) - .delete('/resource-servers/' + id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).delete(`/resource-servers/${id}`).reply(200); }); - it('should accept a callback', function(done) { - this.resourceServers.delete({ id: id }, done.bind(null, null)); + it('should accept a callback', function (done) { + this.resourceServers.delete({ id }, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { - this.resourceServers.delete({ id: id }).then(done.bind(null, null)); + it('should return a promise when no callback is given', function (done) { + this.resourceServers.delete({ id }).then(done.bind(null, null)); }); - it('should perform a DELETE request to /resource-servers/' + id, function(done) { - var request = this.request; + it(`should perform a DELETE request to /resource-servers/${id}`, function (done) { + const { request } = this; - this.resourceServers.delete({ id: id }).then(function() { + this.resourceServers.delete({ id }).then(() => { expect(request.isDone()).to.be.true; done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/resource-servers/' + id) - .reply(500); + nock(API_URL).delete(`/resource-servers/${id}`).reply(500); - this.resourceServers.delete({ id: id }).catch(function(err) { + this.resourceServers.delete({ id }).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/resource-servers/' + id) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .delete(`/resource-servers/${id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.resourceServers.delete({ id: id }).then(function() { + this.resourceServers.delete({ id }).then(() => { expect(request.isDone()).to.be.true; done(); diff --git a/test/management/roles.tests.js b/test/management/roles.tests.js new file mode 100644 index 000000000..de166e947 --- /dev/null +++ b/test/management/roles.tests.js @@ -0,0 +1,711 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenant.auth0.com'; + +const RolesManager = require(`../../src/management/RolesManager`); +const { ArgumentError } = require('rest-facade'); + +describe('RolesManager', () => { + before(function () { + this.token = 'TOKEN'; + this.roles = new RolesManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = [ + 'get', + 'getAll', + 'create', + 'update', + 'delete', + 'getPermissions', + 'addPermissions', + 'removePermissions', + 'getUsers', + 'assignUsers', + ]; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.roles[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new RolesManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new RolesManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new RolesManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/roles').reply(200); + }); + + it('should accept a callback', function (done) { + this.roles.getAll(() => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.roles.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/roles').reply(500); + + this.roles.getAll().catch((err) => { + expect(err).to.exist; + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', async function () { + nock.cleanAll(); + + const data = [{ test: true }]; + nock(API_URL).get('/roles').reply(200, data); + + const credentials = await this.roles.getAll(); + expect(credentials).to.be.an.instanceOf(Array); + + expect(credentials.length).to.equal(data.length); + + expect(credentials[0].test).to.equal(data[0].test); + }); + + it('should perform a GET request to /api/v2/roles', async function () { + const { request } = this; + + await this.roles.getAll(); + expect(request.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async function () { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/roles') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + await this.roles.getAll(); + expect(request.isDone()).to.be.true; + }); + + it('should pass the parameters in the query-string', async function () { + nock.cleanAll(); + + const params = { + include_fields: true, + fields: 'test', + }; + const request = nock(API_URL).get('/roles').query(params).reply(200); + + await this.roles.getAll(params); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#get', () => { + beforeEach(function () { + this.data = { + id: 'rol_ID', + name: 'My role', + description: 'This is my role', + }; + + this.request = nock(API_URL).get(`/roles/${this.data.id}`).reply(200, this.data); + }); + + it('should accept a callback', function (done) { + const params = { id: this.data.id }; + + this.roles.get(params, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.roles.get({ id: this.data.id }).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should perform a POST request to /api/v2/roles/rol_ID', async function () { + const { request } = this; + + await this.roles.get({ id: this.data.id }); + expect(request.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/roles/${this.data.id}`).reply(500); + + this.roles.get({ id: this.data.id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/roles/${this.data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.roles.get({ id: this.data.id }).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#create', () => { + const data = { + id: 'rol_ID', + name: 'My role', + description: 'This is my role', + }; + + beforeEach(function () { + this.request = nock(API_URL).post('/roles').reply(200); + }); + + it('should accept a callback', function (done) { + this.roles.create(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.roles.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post('/roles').reply(500); + + this.roles.create(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/roles', async function () { + const { request } = this; + + await this.roles.create(data); + expect(request.isDone()).to.be.true; + }); + + it('should pass the data in the body of the request', async function () { + nock.cleanAll(); + + const request = nock(API_URL).post('/roles', data).reply(200); + + await this.roles.create(data); + expect(request.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post('/roles') + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.roles.create(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#update', () => { + beforeEach(function () { + this.data = { id: 'rol_ID' }; + + this.request = nock(API_URL).patch(`/roles/${this.data.id}`).reply(200, this.data); + }); + + it('should accept a callback', function (done) { + this.roles.update({ id: 'rol_ID' }, {}, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', function (done) { + this.roles + .update({ id: 'rol_ID' }, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should perform a PATCH request to /api/v2/roles/rol_ID', function (done) { + const { request } = this; + + this.roles.update({ id: 'rol_ID' }, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the new data in the body of the request', async function () { + nock.cleanAll(); + + const request = nock(API_URL).patch(`/roles/${this.data.id}`, this.data).reply(200); + + await this.roles.update({ id: 'rol_ID' }, this.data); + expect(request.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).patch(`/roles/${this.data.id}`).reply(500); + + this.roles.update({ id: this.data.id }, this.data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + }); + + describe('#delete', () => { + const id = 'rol_ID'; + + beforeEach(function () { + this.request = nock(API_URL).delete(`/roles/${id}`).reply(200); + }); + + it('should accept a callback', function (done) { + this.roles.delete({ id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function () { + expect(this.roles.delete({ id })).instanceOf(Promise); + }); + + it(`should perform a delete request to /roles/${id}`, async function () { + const { request } = this; + + await this.roles.delete({ id }); + expect(request.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete(`/roles/${id}`).reply(500); + + this.roles.delete({ id }).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', async function () { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/roles/${id}`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + await this.roles.delete({ id }); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#getPermissions', () => { + const data = { + id: 'role_id', + }; + + beforeEach(function () { + this.request = nock(API_URL).get(`/roles/${data.id}/permissions`).reply(200); + }); + + it('should accept a callback', function (done) { + this.roles.getPermissions(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function () { + expect(this.roles.getPermissions(data)).instanceOf(Promise); + }); + + it('should perform a GET request to /api/v2/roles/rol_ID/permissions', async function () { + const { request } = this; + + await this.roles.getPermissions(data); + expect(request.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/roles/${data.id}/permissions`).reply(500); + + this.roles.getPermissions(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', async function () { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/roles/${data.id}/permissions`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + await this.roles.getPermissions(data); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#addPermissions', () => { + beforeEach(function () { + this.data = { + id: 'rol_ID', + }; + this.body = { permission_name: 'My Permission', resource_server_identifier: 'test123' }; + + this.request = nock(API_URL).post(`/roles/${this.data.id}/permissions`).reply(200); + }); + + it('should accept a callback', function (done) { + this.roles.addPermissions(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.roles + .addPermissions(this.data, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/roles/${this.data.id}/permissions`).reply(500); + + this.roles.addPermissions(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/roles/rol_ID/permissions', async function () { + const { request } = this; + + await this.roles.addPermissions(this.data, {}); + expect(request.isDone()).to.be.true; + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/roles/${this.data.id}/permissions`, this.body) + .reply(200); + + this.roles.addPermissions(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/roles/${this.data.id}/permissions`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.roles.addPermissions(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#removePermissions', () => { + beforeEach(function () { + this.data = { + id: 'rol_ID', + }; + this.body = { permission_name: 'My Permission', resource_server_identifier: 'test123' }; + + this.request = nock(API_URL).delete(`/roles/${this.data.id}/permissions`, {}).reply(200); + }); + + it('should validate empty roleId', function () { + const _this = this; + expect(() => { + _this.roles.removePermissions({ id: null }, _this.body, () => {}); + }).to.throw('The roleId passed in params cannot be null or undefined'); + }); + + it('should validate non-string roleId', function () { + const _this = this; + expect(() => { + _this.roles.removePermissions({ id: 123 }, _this.body, () => {}); + }).to.throw('The role Id has to be a string'); + }); + + it('should accept a callback', function (done) { + this.roles.removePermissions(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.roles + .removePermissions(this.data, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/roles/${this.data.id}/permissions`).reply(500); + + this.roles.removePermissions(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a DELETE request to /api/v2/roles/rol_ID/permissions', function (done) { + const { request } = this; + + this.roles.removePermissions(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/roles/${this.data.id}/permissions`, this.body) + .reply(200); + + this.roles.removePermissions(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/roles/${this.data.id}/permissions`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.roles.removePermissions(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#getUsers', () => { + const data = { + id: 'role_id', + }; + + beforeEach(function () { + this.request = nock(API_URL).get(`/roles/${data.id}/users`).reply(200); + }); + + it('should accept a callback', function (done) { + this.roles.getUsers(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function (done) { + this.roles.getUsers(data).then(done.bind(null, null)); + }); + + it('should perform a GET request to /api/v2/roles/rol_Id/users', function (done) { + const { request } = this; + + this.roles.getUsers(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/roles/${data.id}/users`).reply(500); + + this.roles.getUsers(data).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should include the token in the authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/roles/${data.id}/users`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + this.roles.getUsers(data).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); + + describe('#assignUsers', () => { + beforeEach(function () { + this.data = { + id: 'rol_ID', + }; + this.body = { users: ['userID1'] }; + + this.request = nock(API_URL).post(`/roles/${this.data.id}/users`).reply(200); + }); + + it('should validate empty roleId', function () { + const _this = this; + expect(() => { + _this.roles.assignUsers({ id: null }, _this.body, () => {}); + }).to.throw('The roleId passed in params cannot be null or undefined'); + }); + + it('should validate non-string roleId', function () { + const _this = this; + expect(() => { + _this.roles.assignUsers({ id: 123 }, _this.body, () => {}); + }).to.throw('The role Id has to be a string'); + }); + + it('should accept a callback', function (done) { + this.roles.assignUsers(this.data, {}, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', function (done) { + this.roles + .assignUsers(this.data, {}) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).post(`/roles/${this.data.id}/users`).reply(500); + + this.roles.assignUsers(this.data, {}).catch((err) => { + expect(err).to.exist; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/roles/rol_ID/users', function (done) { + const { request } = this; + + this.roles.assignUsers(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should perform a POST request to /api/v2/roles/rol_ID/users with a callback', function (done) { + const { request } = this; + + this.roles.assignUsers(this.data, {}, () => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should pass the data in the body of the request', function (done) { + nock.cleanAll(); + + const request = nock(API_URL).post(`/roles/${this.data.id}/users`, this.body).reply(200); + + this.roles.assignUsers(this.data, this.body).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + + it('should include the token in the Authorization header', function (done) { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/roles/${this.data.id}/users`) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + + this.roles.assignUsers(this.data, {}).then(() => { + expect(request.isDone()).to.be.true; + + done(); + }); + }); + }); +}); diff --git a/test/management/rules-configs.tests.js b/test/management/rules-configs.tests.js index 691e0e0a3..4de74bb89 100644 --- a/test/management/rules-configs.tests.js +++ b/test/management/rules-configs.tests.js @@ -1,197 +1,135 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var RulesConfigsManager = require(SRC_DIR + '/management/RulesConfigsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const RulesConfigsManager = require(`../../src/management/RulesConfigsManager`); +const { ArgumentError } = require('rest-facade'); - -describe('RulesConfigsManager', function () { +describe('RulesConfigsManager', () => { before(function () { this.token = 'TOKEN'; this.rulesConfigs = new RulesConfigsManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function () { - var methods = ['set', 'getAll', 'delete']; + describe('instance', () => { + const methods = ['set', 'getAll', 'delete']; - methods.forEach(function (method) { - it('should have a ' + method + ' method', function () { - expect(this.rulesConfigs[method]) - .to.exist - .to.be.an.instanceOf(Function); - }) + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.rulesConfigs[method]).to.exist.to.be.an.instanceOf(Function); + }); }); }); - describe('#constructor', function () { - it('should error when no options are provided', function () { - expect(RulesConfigsManager) - .to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new RulesConfigsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - - it('should throw an error when no base URL is provided', function () { - var client = RulesConfigsManager.bind(null, {}); - - expect(client) - .to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new RulesConfigsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - - it('should throw an error when the base URL is invalid', function () { - var client = RulesConfigsManager.bind(null, { baseUrl: '' }); - - expect(client) - .to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new RulesConfigsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function () { - + describe('#getAll', () => { it('should accept a callback', function (done) { - this - .rulesConfigs - .getAll(function () { - done(); - }); + this.rulesConfigs.getAll(() => { + done(); + }); }); - it('should return a promise if no callback is given', function (done) { - this - .rulesConfigs - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + this.rulesConfigs.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/rules-configs') - .reply(500); - - this - .rulesConfigs - .getAll() - .catch(function (err) { - expect(err).to.exist; - done(); - }); - }); + nock(API_URL).get('/rules-configs').reply(500); + this.rulesConfigs.getAll().catch((err) => { + expect(err).to.exist; + done(); + }); + }); - it('should pass the body of the response to the "then" handler', function (done) { + it('should pass the body of the response to the "then" handler', async function () { nock.cleanAll(); - var data = [{ key: 'dbconnectionstring' }]; - var request = nock(API_URL) - .get('/rules-configs') - .reply(200, data); + const data = [{ key: 'dbconnectionstring' }]; + nock(API_URL).get('/rules-configs').reply(200, data); - this - .rulesConfigs - .getAll() - .then(function (rulesConfigs) { - expect(rulesConfigs) - .to.be.an.instanceOf(Array); + const rulesConfigs = await this.rulesConfigs.getAll(); + expect(rulesConfigs).to.be.an.instanceOf(Array); - expect(rulesConfigs.length) - .to.equal(data.length); + expect(rulesConfigs.length).to.equal(data.length); - expect(rulesConfigs[0].key) - .to.equal(data[0].key); - - done(); - }); + expect(rulesConfigs[0].key).to.equal(data[0].key); }); - - it('should perform a GET request to rules-configs', function (done) { + it('should perform a GET request to rules-configs', async function () { nock.cleanAll(); - var request = nock(API_URL) - .get('/rules-configs') - .reply(200); + const request = nock(API_URL).get('/rules-configs').reply(200); - this - .rulesConfigs - .getAll() - .then(function () { - expect(request.isDone()).to.be.true; - done(); - }); + await this.rulesConfigs.getAll(); + expect(request.isDone()).to.be.true; }); - - it('should include the token in the Authorization header', function (done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/rules-configs') - .matchHeader('Authorization', 'Bearer ' + this.token) - .reply(200) - - this - .rulesConfigs - .getAll() - .then(function () { - expect(request.isDone()).to.be.true; - done(); - }); - }); + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); + await this.rulesConfigs.getAll(); + expect(request.isDone()).to.be.true; + }); - it('should pass the parameters in the query-string', function (done) { + it('should pass the parameters in the query-string', async function () { nock.cleanAll(); - var params = { + const params = { include_fields: true, - fields: 'test' + fields: 'test', }; - var request = nock(API_URL) - .get('/rules-configs') - .query(params) - .reply(200) - - this - .rulesConfigs - .getAll(params) - .then(function () { - expect(request.isDone()) - .to.be.true; - - done(); - }); + const request = nock(API_URL).get('/rules-configs').query(params).reply(200); + + await this.rulesConfigs.getAll(params); + expect(request.isDone()).to.be.true; }); }); - describe('#set', function () { - + describe('#set', () => { beforeEach(function () { this.data = { value: 'foobar' }; this.params = { key: 'KEY' }; }); it('should accept a callback', function (done) { - this - .rulesConfigs - .set(this.params, this.data, function () { - done(); - }); + this.rulesConfigs.set(this.params, this.data, () => { + done(); + }); }); it('should return a promise if no callback is given', function (done) { - this - .rulesConfigs + this.rulesConfigs .set(this.params, this.data) .then(done.bind(null, null)) .catch(done.bind(null, null)); @@ -200,158 +138,90 @@ describe('RulesConfigsManager', function () { it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .put('/rules-configs/' + this.params.key) - .reply(500); + nock(API_URL).put(`/rules-configs/${this.params.key}`).reply(500); - this - .rulesConfigs - .set(this.params, this.data) - .catch(function (err) { - expect(err) - .to.exist; + this.rulesConfigs.set(this.params, this.data).catch((err) => { + expect(err).to.exist; - done(); - }); + done(); + }); }); - it('should perform a PUT request to /rules-configs/{KEY}', function (done) { + it('should perform a PUT request to /rules-configs/{KEY}', async function () { nock.cleanAll(); - var request = nock(API_URL) - .put('/rules-configs/' + this.params.key, this.data) - .reply(200); + const request = nock(API_URL).put(`/rules-configs/${this.params.key}`, this.data).reply(200); - this - .rulesConfigs - .set(this.params, this.data) - .then(function () { - expect(request.isDone()) - .to.be.true; - - done(); - }) - .catch(function (err) { - console.error(err); - expect.fail(); - done(); - }); + await this.rulesConfigs.set(this.params, this.data); + expect(request.isDone()).to.be.true; }); - it('should pass the data in the body of the request', function (done) { + it('should pass the data in the body of the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .put('/rules-configs/' + this.params.key, this.data) - .reply(200); + const request = nock(API_URL).put(`/rules-configs/${this.params.key}`, this.data).reply(200); - this - .rulesConfigs - .set(this.params, this.data) - .then(function () { - expect(request.isDone()) - .to.be.true; - - done(); - }); + await this.rulesConfigs.set(this.params, this.data); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function (done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) - .put('/rules-configs/' + this.params.key, this.data) - .matchHeader('Authorization', 'Bearer ' + this.token) - .reply(200) - - this - .rulesConfigs - .set(this.params, this.data) - .then(function () { - expect(request.isDone()) - .to.be.true; + const request = nock(API_URL) + .put(`/rules-configs/${this.params.key}`, this.data) + .matchHeader('Authorization', `Bearer ${this.token}`) + .reply(200); - done(); - }); + await this.rulesConfigs.set(this.params, this.data); + expect(request.isDone()).to.be.true; }); }); - describe('#delete', function () { - var key = 'KEY'; + describe('#delete', () => { + const key = 'KEY'; beforeEach(function () { - this.request = nock(API_URL) - .delete('/rules-configs/' + key) - .reply(200); + this.request = nock(API_URL).delete(`/rules-configs/${key}`).reply(200); }); - it('should accept a callback', function (done) { - this - .rulesConfigs - .delete({ key: key }, done.bind(null, null)); + this.rulesConfigs.delete({ key }, done.bind(null, null)); }); - - it('should return a promise when no callback is given', function (done) { - this - .rulesConfigs - .delete({ key: key }) - .then(done.bind(null, null)); + it('should return a promise when no callback is given', function () { + expect(this.rulesConfigs.delete({ key })).instanceOf(Promise); }); + it(`should perform a delete request to /rules-configs/${key}`, async function () { + const { request } = this; - it('should perform a delete request to /rules-configs/' + key, function (done) { - var request = this.request; - - this - .rulesConfigs - .delete({ key: key }) - .then(function () { - expect(request.isDone()) - .to.be.true; - - done(); - }); + await this.rulesConfigs.delete({ key }); + expect(request.isDone()).to.be.true; }); - it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/rules-configs/' + key) - .reply(500); + nock(API_URL).delete(`/rules-configs/${key}`).reply(500); - this - .rulesConfigs - .delete({ key: key }) - .catch(function (err) { - expect(err) - .to.exist; + this.rulesConfigs.delete({ key }).catch((err) => { + expect(err).to.exist; - done(); - }); + done(); + }); }); - - it('should include the token in the authorization header', function (done) { + it('should include the token in the authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) - .delete('/rules-configs/' + key) - .matchHeader('authorization', 'Bearer ' + this.token) - .reply(200) - - this - .rulesConfigs - .delete({ key: key }) - .then(function () { - expect(request.isDone()) - .to.be.true; + const request = nock(API_URL) + .delete(`/rules-configs/${key}`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); - done(); - }); + await this.rulesConfigs.delete({ key }); + expect(request.isDone()).to.be.true; }); }); -}); \ No newline at end of file +}); diff --git a/test/management/rules.tests.js b/test/management/rules.tests.js index dcf900952..9a2837243 100644 --- a/test/management/rules.tests.js +++ b/test/management/rules.tests.js @@ -1,346 +1,279 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var RulesManager = require(SRC_DIR + '/management/RulesManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const RulesManager = require(`../../src/management/RulesManager`); +const { ArgumentError } = require('rest-facade'); -describe('RulesManager', function() { - before(function() { +describe('RulesManager', () => { + before(function () { this.token = 'TOKEN'; this.rules = new RulesManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['get', 'getAll', 'create', 'update', 'delete']; + describe('instance', () => { + const methods = ['get', 'getAll', 'create', 'update', 'delete']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.rules[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(RulesManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new RulesManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = RulesManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new RulesManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = RulesManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new RulesManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/rules') - .reply(200); + describe('#getAll', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/rules').reply(200); }); - it('should accept a callback', function(done) { - this.rules.getAll(function() { + it('should accept a callback', function (done) { + this.rules.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.rules - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.rules.getAll().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/rules') - .reply(500); + nock(API_URL).get('/rules').reply(500); - this.rules.getAll().catch(function(err) { + this.rules.getAll().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', async function () { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/rules') - .reply(200, data); - - this.rules.getAll().then(function(credentials) { - expect(credentials).to.be.an.instanceOf(Array); + const data = [{ test: true }]; + nock(API_URL).get('/rules').reply(200, data); - expect(credentials.length).to.equal(data.length); + const credentials = await this.rules.getAll(); + expect(credentials).to.be.an.instanceOf(Array); - expect(credentials[0].test).to.equal(data[0].test); + expect(credentials.length).to.equal(data.length); - done(); - }); + expect(credentials[0].test).to.equal(data[0].test); }); - it('should perform a GET request to /api/v2/rules', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/rules', async function () { + const { request } = this; - this.rules.getAll().then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.rules.getAll(); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/rules') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.rules.getAll().then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.rules.getAll(); + expect(request.isDone()).to.be.true; }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', async function () { nock.cleanAll(); - var params = { + const params = { include_fields: true, - fields: 'test' + fields: 'test', }; - var request = nock(API_URL) - .get('/rules') - .query(params) - .reply(200); + const request = nock(API_URL).get('/rules').query(params).reply(200); - this.rules.getAll(params).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await this.rules.getAll(params); + expect(request.isDone()).to.be.true; }); }); - describe('#get', function() { - beforeEach(function() { + describe('#get', () => { + beforeEach(function () { this.data = { id: 5, name: 'Test rule', enabled: true, script: "function (user, contest, callback) { console.log('Test'); }", - stage: 'login_success' + stage: 'login_success', }; - this.request = nock(API_URL) - .get('/rules/' + this.data.id) - .reply(200, this.data); + this.request = nock(API_URL).get(`/rules/${this.data.id}`).reply(200, this.data); }); - it('should accept a callback', function(done) { - var params = { id: this.data.id }; + it('should accept a callback', function (done) { + const params = { id: this.data.id }; this.rules.get(params, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { - this.rules - .get({ id: this.data.id }) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.rules.get({ id: this.data.id }).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a POST request to /api/v2/rules/5', function(done) { - var request = this.request; - - this.rules.get({ id: this.data.id }).then(function() { - expect(request.isDone()).to.be.true; + it('should perform a POST request to /api/v2/rules/5', async function () { + const { request } = this; - done(); - }); + await this.rules.get({ id: this.data.id }); + expect(request.isDone()).to.be.true; }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/rules/' + this.data.id) - .reply(500); + nock(API_URL).get(`/rules/${this.data.id}`).reply(500); - this.rules.get({ id: this.data.id }).catch(function(err) { + this.rules.get({ id: this.data.id }).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) - .get('/rules/' + this.data.id) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .get(`/rules/${this.data.id}`) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.rules.get({ id: this.data.id }).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await this.rules.get({ id: this.data.id }); + expect(request.isDone()).to.be.true; }); }); - describe('#create', function() { - var data = { + describe('#create', () => { + const data = { id: 5, name: 'Test rule', enabled: true, script: "function (user, contest, callback) { console.log('Test'); }", - stage: 'login_success' + stage: 'login_success', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/rules') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/rules').reply(200); }); - it('should accept a callback', function(done) { - this.rules.create(data, function() { + it('should accept a callback', function (done) { + this.rules.create(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.rules - .create(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.rules.create(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/rules') - .reply(500); + nock(API_URL).post('/rules').reply(500); - this.rules.create(data).catch(function(err) { + this.rules.create(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2/rules', function(done) { - var request = this.request; - - this.rules.create(data).then(function() { - expect(request.isDone()).to.be.true; + it('should perform a POST request to /api/v2/rules', async function () { + const { request } = this; - done(); - }); + await this.rules.create(data); + expect(request.isDone()).to.be.true; }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post('/rules', data) - .reply(200); - - this.rules.create(data).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).post('/rules', data).reply(200); - done(); - }); + await this.rules.create(data); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/rules') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.rules.create(data).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await this.rules.create(data); + expect(request.isDone()).to.be.true; }); }); - describe('#update', function() { - beforeEach(function() { + describe('#update', () => { + beforeEach(function () { this.data = { id: 5 }; - this.request = nock(API_URL) - .patch('/rules/' + this.data.id) - .reply(200, this.data); + this.request = nock(API_URL).patch(`/rules/${this.data.id}`).reply(200, this.data); }); - it('should accept a callback', function(done) { + it('should accept a callback', function (done) { this.rules.update({ id: 5 }, {}, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { - this.rules - .update({ id: 5 }, {}) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.rules.update({ id: 5 }, {}).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should perform a PATCH request to /api/v2/rules/5', function(done) { - var request = this.request; - - this.rules.update({ id: 5 }, {}).then(function() { - expect(request.isDone()).to.be.true; + it('should perform a PATCH request to /api/v2/rules/5', async function () { + const { request } = this; - done(); - }); + await this.rules.update({ id: 5 }, {}); + expect(request.isDone()).to.be.true; }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .patch('/rules/' + this.data.id, this.data) - .reply(200); - - this.rules.update({ id: 5 }, this.data).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).patch(`/rules/${this.data.id}`, this.data).reply(200); - done(); - }); + await this.rules.update({ id: 5 }, this.data); + expect(request.isDone()).to.be.true; }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/rules/' + this.data.id) - .reply(500); + nock(API_URL).patch(`/rules/${this.data.id}`).reply(500); - this.rules.update({ id: this.data.id }, this.data).catch(function(err) { + this.rules.update({ id: this.data.id }, this.data).catch((err) => { expect(err).to.exist; done(); @@ -348,60 +281,50 @@ describe('RulesManager', function() { }); }); - describe('#delete', function() { - var id = 5; + describe('#delete', () => { + const id = 5; - beforeEach(function() { - this.request = nock(API_URL) - .delete('/rules/' + id) - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).delete(`/rules/${id}`).reply(200); }); - it('should accept a callback', function(done) { - this.rules.delete({ id: id }, done.bind(null, null)); + it('should accept a callback', function (done) { + this.rules.delete({ id }, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { - this.rules.delete({ id: id }).then(done.bind(null, null)); + it('should return a promise when no callback is given', function () { + expect(this.rules.delete({ id })).instanceOf(Promise); }); - it('should perform a delete request to /rules/' + id, function(done) { - var request = this.request; + it(`should perform a delete request to /rules/${id}`, async function () { + const { request } = this; - this.rules.delete({ id: id }).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await this.rules.delete({ id }); + expect(request.isDone()).to.be.true; }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .delete('/rules/' + id) - .reply(500); + nock(API_URL).delete(`/rules/${id}`).reply(500); - this.rules.delete({ id: id }).catch(function(err) { + this.rules.delete({ id }).catch((err) => { expect(err).to.exist; done(); }); }); - it('should include the token in the authorization header', function(done) { + it('should include the token in the authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) - .delete('/rules/' + id) - .matchHeader('authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .delete(`/rules/${id}`) + .matchHeader('authorization', `Bearer ${this.token}`) .reply(200); - this.rules.delete({ id: id }).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await this.rules.delete({ id }); + expect(request.isDone()).to.be.true; }); }); }); diff --git a/test/management/stats.tests.js b/test/management/stats.tests.js index eac10c623..d70b43b42 100644 --- a/test/management/stats.tests.js +++ b/test/management/stats.tests.js @@ -1,210 +1,177 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenant.auth0.com'; +const API_URL = 'https://tenant.auth0.com'; -var StatsManager = require(SRC_DIR + '/management/StatsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const StatsManager = require(`../../src/management/StatsManager`); +const { ArgumentError } = require('rest-facade'); -describe('StatsManager', function() { - before(function() { +describe('StatsManager', () => { + before(function () { this.token = 'TOKEN'; this.stats = new StatsManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['getActiveUsersCount', 'getDaily']; + describe('instance', () => { + const methods = ['getActiveUsersCount', 'getDaily']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.stats[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(StatsManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new StatsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var client = StatsManager.bind(null, {}); - - expect(client).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new StatsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var client = StatsManager.bind(null, { baseUrl: '' }); - - expect(client).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new StatsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getDaily', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/stats/daily') - .reply(200); + describe('#getDaily', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/stats/daily').reply(200); }); - it('should accept a callback', function(done) { - this.stats.getDaily({}, function() { + it('should accept a callback', function (done) { + this.stats.getDaily({}, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.stats - .getDaily() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.stats.getDaily().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/stats/daily') - .reply(500); + nock(API_URL).get('/stats/daily').reply(500); - this.stats.getDaily().catch(function(err) { + this.stats.getDaily().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', async function () { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/stats/daily') - .reply(200, data); - - this.stats.getDaily().then(function(blacklistedTokens) { - expect(blacklistedTokens).to.be.an.instanceOf(Array); + const data = [{ test: true }]; + nock(API_URL).get('/stats/daily').reply(200, data); - expect(blacklistedTokens.length).to.equal(data.length); + const blacklistedTokens = await this.stats.getDaily(); + expect(blacklistedTokens).to.be.an.instanceOf(Array); - expect(blacklistedTokens[0].test).to.equal(data[0].test); + expect(blacklistedTokens.length).to.equal(data.length); - done(); - }); + expect(blacklistedTokens[0].test).to.equal(data[0].test); }); - it('should perform a GET request to /api/v2/stats/daily', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/stats/daily', async function () { + const { request } = this; - this.stats.getDaily().then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.stats.getDaily(); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/stats/daily') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.stats.getDaily().then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.stats.getDaily(); + expect(request.isDone()).to.be.true; }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/stats/daily') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.stats.getDaily({ include_fields: true, fields: 'test' }).then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.stats.getDaily({ include_fields: true, fields: 'test' }); + expect(request.isDone()).to.be.true; }); }); - describe('#getActiveUsersCount', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/stats/active-users') - .reply(200); + describe('#getActiveUsersCount', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/stats/active-users').reply(200); }); - it('should accept a callback', function(done) { - this.stats.getActiveUsersCount(function() { + it('should accept a callback', function (done) { + this.stats.getActiveUsersCount(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.stats - .getActiveUsersCount() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.stats.getActiveUsersCount().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/stats/active-users') - .reply(500); + nock(API_URL).get('/stats/active-users').reply(500); - this.stats.getActiveUsersCount().catch(function(err) { + this.stats.getActiveUsersCount().catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a GET request to /api/v2/stats/active-users', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/stats/active-users', async function () { + const { request } = this; - this.stats.getActiveUsersCount().then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.stats.getActiveUsersCount(); + expect(request.isDone()).to.be.true; }); - it('should pass the token data in the body of the request', function(done) { + it('should pass the token data in the body of the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .get('/stats/active-users') - .reply(200); - - this.stats.getActiveUsersCount().then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).get('/stats/active-users').reply(200); - done(); - }); + await this.stats.getActiveUsersCount(); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/stats/active-users') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.stats.getActiveUsersCount().then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.stats.getActiveUsersCount(); + expect(request.isDone()).to.be.true; }); }); }); diff --git a/test/management/tenant.tests.js b/test/management/tenant.tests.js index 0b541a6a4..95a182c01 100644 --- a/test/management/tenant.tests.js +++ b/test/management/tenant.tests.js @@ -1,214 +1,181 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenants.auth0.com'; +const API_URL = 'https://tenants.auth0.com'; -var TenantManager = require(SRC_DIR + '/management/TenantManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const TenantManager = require(`../../src/management/TenantManager`); +const { ArgumentError } = require('rest-facade'); -describe('TenantManager', function() { - before(function() { +describe('TenantManager', () => { + before(function () { this.token = 'TOKEN'; this.tenant = new TenantManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['updateSettings', 'getSettings']; + describe('instance', () => { + const methods = ['updateSettings', 'getSettings']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.tenant[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(TenantManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new TenantManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var manager = TenantManager.bind(null, {}); - - expect(manager).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new TenantManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var manager = TenantManager.bind(null, { baseUrl: '' }); - - expect(manager).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new TenantManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getSettings', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/tenants/settings') - .reply(200); + describe('#getSettings', () => { + beforeEach(function () { + this.request = nock(API_URL).get('/tenants/settings').reply(200); }); - it('should accept a callback', function(done) { - this.tenant.getSettings(function() { + it('should accept a callback', function (done) { + this.tenant.getSettings(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.tenant - .getSettings() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.tenant.getSettings().then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .get('/tenants/settings') - .reply(500); + nock(API_URL).get('/tenants/settings').reply(500); - this.tenant.getSettings().catch(function(err) { + this.tenant.getSettings().catch((err) => { expect(err).to.exist; done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', async function () { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/tenants/settings') - .reply(200, data); - - this.tenant.getSettings().then(function(blacklistedTokens) { - expect(blacklistedTokens).to.be.an.instanceOf(Array); + const data = [{ test: true }]; + nock(API_URL).get('/tenants/settings').reply(200, data); - expect(blacklistedTokens.length).to.equal(data.length); + const blacklistedTokens = await this.tenant.getSettings(); + expect(blacklistedTokens).to.be.an.instanceOf(Array); - expect(blacklistedTokens[0].test).to.equal(data[0].test); + expect(blacklistedTokens.length).to.equal(data.length); - done(); - }); + expect(blacklistedTokens[0].test).to.equal(data[0].test); }); - it('should perform a GET request to /api/v2/tenants/settings', function(done) { - var request = this.request; + it('should perform a GET request to /api/v2/tenants/settings', async function () { + const { request } = this; - this.tenant.getSettings().then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tenant.getSettings(); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/tenants/settings') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.tenant.getSettings().then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tenant.getSettings(); + expect(request.isDone()).to.be.true; }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/tenants/settings') .query({ include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.tenant.getSettings({ include_fields: true, fields: 'test' }).then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tenant.getSettings({ include_fields: true, fields: 'test' }); + expect(request.isDone()).to.be.true; }); }); - describe('#updateSettings', function() { - var data = { - friendly_name: 'Test name' + describe('#updateSettings', () => { + const data = { + friendly_name: 'Test name', }; - beforeEach(function() { - this.request = nock(API_URL) - .patch('/tenants/settings') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).patch('/tenants/settings').reply(200); }); - it('should accept a callback', function(done) { - this.tenant.updateSettings(data, function() { + it('should accept a callback', function (done) { + this.tenant.updateSettings(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.tenant - .updateSettings(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.tenant.updateSettings(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .patch('/tenants/settings') - .reply(500); + nock(API_URL).patch('/tenants/settings').reply(500); - this.tenant.updateSettings(data).catch(function(err) { + this.tenant.updateSettings(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a PATCH request to /api/v2/tenants/settings', function(done) { - var request = this.request; + it('should perform a PATCH request to /api/v2/tenants/settings', async function () { + const { request } = this; - this.tenant.updateSettings(data).then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tenant.updateSettings(data); + expect(request.isDone()).to.be.true; }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .patch('/tenants/settings', data) - .reply(200); - - this.tenant.updateSettings(data).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).patch('/tenants/settings', data).reply(200); - done(); - }); + await this.tenant.updateSettings(data); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .patch('/tenants/settings') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.tenant.updateSettings(data).then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tenant.updateSettings(data); + expect(request.isDone()).to.be.true; }); }); }); diff --git a/test/management/tickets.tests.js b/test/management/tickets.tests.js index 5185844bd..282457fdd 100644 --- a/test/management/tickets.tests.js +++ b/test/management/tickets.tests.js @@ -1,205 +1,175 @@ -var expect = require('chai').expect; -var nock = require('nock'); +const { expect } = require('chai'); +const nock = require('nock'); -var SRC_DIR = '../../src'; -var API_URL = 'https://tenants.auth0.com'; +const API_URL = 'https://tenants.auth0.com'; -var TicketsManager = require(SRC_DIR + '/management/TicketsManager'); -var ArgumentError = require('rest-facade').ArgumentError; +const TicketsManager = require(`../../src/management/TicketsManager`); +const { ArgumentError } = require('rest-facade'); -describe('TicketsManager', function() { - before(function() { +describe('TicketsManager', () => { + before(function () { this.token = 'TOKEN'; this.tickets = new TicketsManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = ['changePassword', 'verifyEmail']; + describe('instance', () => { + const methods = ['changePassword', 'verifyEmail']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, function () { expect(this.tickets[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(TicketsManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new TicketsManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var manager = TicketsManager.bind(null, {}); - - expect(manager).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new TicketsManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var manager = TicketsManager.bind(null, { baseUrl: '' }); - - expect(manager).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new TicketsManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#verifyEmail', function() { - var data = { + describe('#verifyEmail', () => { + const data = { result_url: 'http://myapp.com/callback', - user_id: '' + user_id: '', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/tickets/email-verification') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/tickets/email-verification').reply(200); }); - it('should accept a callback', function(done) { - this.tickets.verifyEmail(data, function() { + it('should accept a callback', function (done) { + this.tickets.verifyEmail(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.tickets - .verifyEmail(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.tickets.verifyEmail(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('tickets/email-verification') - .reply(500); + nock(API_URL).post('/tickets/email-verification').reply(500); - this.tickets.verifyEmail(data).catch(function(err) { + this.tickets.verifyEmail(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2tickets/email-verification', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2tickets/email-verification', async function () { + const { request } = this; - this.tickets.verifyEmail(data).then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tickets.verifyEmail(data); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/tickets/email-verification') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.tickets.verifyEmail({}).then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tickets.verifyEmail({}); + expect(request.isDone()).to.be.true; }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post('/tickets/email-verification') - .query({ + const request = nock(API_URL) + .post('/tickets/email-verification', { include_fields: true, - fields: 'test' + fields: 'test', }) .reply(200); - this.tickets.verifyEmail({ include_fields: true, fields: 'test' }).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await this.tickets.verifyEmail({ include_fields: true, fields: 'test' }); + expect(request.isDone()).to.be.true; }); }); - describe('#changePassword', function() { - var data = { + describe('#changePassword', () => { + const data = { result_url: 'http://myapp.com/callback', user_id: '', new_password: 'secret', connection_id: 'con_0000000000000001', - email: '' + email: '', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/tickets/password-change') - .reply(200); + beforeEach(function () { + this.request = nock(API_URL).post('/tickets/password-change').reply(200); }); - it('should accept a callback', function(done) { - this.tickets.changePassword(data, function() { + it('should accept a callback', function (done) { + this.tickets.changePassword(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.tickets - .changePassword(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', function (done) { + this.tickets.changePassword(data).then(done.bind(null, null)).catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', function (done) { nock.cleanAll(); - var request = nock(API_URL) - .post('/tickets/email-verification') - .reply(500); + nock(API_URL).post('/tickets/email-verification').reply(500); - this.tickets.changePassword(data).catch(function(err) { + this.tickets.changePassword(data).catch((err) => { expect(err).to.exist; done(); }); }); - it('should perform a POST request to /api/v2tickets/email-verification', function(done) { - var request = this.request; + it('should perform a POST request to /api/v2tickets/email-verification', async function () { + const { request } = this; - this.tickets.changePassword(data).then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tickets.changePassword(data); + expect(request.isDone()).to.be.true; }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', async function () { nock.cleanAll(); - var request = nock(API_URL) - .post('/tickets/password-change', data) - .reply(200); - - this.tickets.changePassword(data).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).post('/tickets/password-change', data).reply(200); - done(); - }); + await this.tickets.changePassword(data); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async function () { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/tickets/password-change') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${this.token}`) .reply(200); - this.tickets.changePassword(data).then(function() { - expect(request.isDone()).to.be.true; - done(); - }); + await this.tickets.changePassword(data); + expect(request.isDone()).to.be.true; }); }); }); diff --git a/test/management/user-blocks.tests.js b/test/management/user-blocks.tests.js new file mode 100644 index 000000000..06aff914f --- /dev/null +++ b/test/management/user-blocks.tests.js @@ -0,0 +1,303 @@ +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenants.auth0.com'; + +const UserBlocksManager = require(`../../src/management/UserBlocksManager`); +const { ArgumentError } = require('rest-facade'); + +describe('UserBlocksManager', () => { + before(function () { + this.token = 'TOKEN'; + this.userBlocks = new UserBlocksManager({ + headers: { authorization: `Bearer ${this.token}` }, + baseUrl: API_URL, + }); + }); + + describe('instance', () => { + const methods = ['get', 'delete', 'getByIdentifier', 'deleteByIdentifier']; + + methods.forEach((method) => { + it(`should have a ${method} method`, function () { + expect(this.userBlocks[method]).to.exist.to.be.an.instanceOf(Function); + }); + }); + }); + + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new UserBlocksManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); + }); + + it('should throw an error when no base URL is provided', () => { + expect(() => { + new UserBlocksManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); + }); + + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new UserBlocksManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); + }); + }); + + describe('#get', () => { + const id = 'USER_5'; + + beforeEach(function () { + this.request = nock(API_URL).get(`/user-blocks/${id}`).reply(200); + }); + + afterEach(() => { + nock.cleanAll(); + }); + + it('should throw an error when no id is provided', function () { + const { userBlocks } = this; + + expect(() => { + userBlocks.get({}); + }).to.throw(ArgumentError, 'You must provide an user id for the get method'); + }); + + it('should accept a callback', function (done) { + this.userBlocks.get({ id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function () { + expect(this.userBlocks.get({ id })).instanceOf(Promise); + }); + + it(`should perform a get request to /user-blocks/${id}`, async function () { + const { request } = this; + + await this.userBlocks.get({ id }); + expect(request.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get(`/user-blocks/${id}`).reply(500); + + this.userBlocks + .get({ id }) + .catch((err) => { + expect(err).to.exist; + + done(); + }) + .catch(done); + }); + + it('should include the token in the authorization header', async function () { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/user-blocks/${id}`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + await this.userBlocks.get({ id }); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#delete', () => { + const id = 'USER_5'; + + beforeEach(function () { + this.request = nock(API_URL).delete(`/user-blocks/${id}`).reply(200); + }); + + afterEach(() => { + nock.cleanAll(); + }); + + it('should throw an error when no id is provided', function () { + const { userBlocks } = this; + + expect(() => { + userBlocks.delete({}); + }).to.throw(ArgumentError, 'You must provide an user id for the delete method'); + }); + + it('should accept a callback', function (done) { + this.userBlocks.delete({ id }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function () { + expect(this.userBlocks.delete({ id })).instanceOf(Promise); + }); + + it(`should perform a delete request to /user-blocks/${id}`, async function () { + const { request } = this; + + await this.userBlocks.delete({ id }); + expect(request.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete(`/user-blocks/${id}`).reply(500); + + this.userBlocks + .delete({ id }) + .catch((err) => { + expect(err).to.exist; + + done(); + }) + .catch(done); + }); + + it('should include the token in the authorization header', async function () { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(`/user-blocks/${id}`) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + await this.userBlocks.delete({ id }); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#getByIdentifier', () => { + const identifier = 'USER_5'; + + beforeEach(function () { + this.request = nock(API_URL).get('/user-blocks').query({ identifier }).reply(200); + }); + + afterEach(() => { + nock.cleanAll(); + }); + + it('should throw an error when no identifier is provided', function () { + const { userBlocks } = this; + + expect(() => { + userBlocks.getByIdentifier({}); + }).to.throw( + ArgumentError, + 'You must provide an user identifier for the getByIdentifier method' + ); + }); + + it('should accept a callback', function (done) { + this.userBlocks.getByIdentifier({ identifier }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function () { + expect(this.userBlocks.getByIdentifier({ identifier })).instanceOf(Promise); + }); + + it('should perform a get request to /user-blocks', async function () { + const { request } = this; + + await this.userBlocks.getByIdentifier({ identifier }); + expect(request.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).get('/user-blocks').query({ identifier }).reply(500); + + this.userBlocks + .getByIdentifier({ identifier }) + .catch((err) => { + expect(err).to.exist; + + done(); + }) + .catch(done); + }); + + it('should include the token in the authorization header', async function () { + nock.cleanAll(); + + const request = nock(API_URL) + .get('/user-blocks') + .query({ identifier }) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + await this.userBlocks.getByIdentifier({ identifier }); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#deleteByIdentifier', () => { + const identifier = 'USER_5'; + + beforeEach(function () { + this.request = nock(API_URL).delete('/user-blocks').query({ identifier }).reply(200); + }); + + afterEach(() => { + nock.cleanAll(); + }); + + it('should throw an error when no identifier is provided', function () { + const { userBlocks } = this; + + expect(() => { + userBlocks.deleteByIdentifier({}); + }).to.throw( + ArgumentError, + 'You must provide an user identifier for the deleteByIdentifier method' + ); + }); + + it('should accept a callback', function (done) { + this.userBlocks.deleteByIdentifier({ identifier }, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', function () { + expect(this.userBlocks.deleteByIdentifier({ identifier })).instanceOf(Promise); + }); + + it('should perform a delete request to /user-blocks', async function () { + const { request } = this; + + await this.userBlocks.deleteByIdentifier({ identifier }); + expect(request.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', function (done) { + nock.cleanAll(); + + nock(API_URL).delete('/user-blocks').query({ identifier }).reply(500); + + this.userBlocks + .deleteByIdentifier({ identifier }) + .catch((err) => { + expect(err).to.exist; + + done(); + }) + .catch(done); + }); + + it('should include the token in the authorization header', async function () { + nock.cleanAll(); + + const request = nock(API_URL) + .delete('/user-blocks') + .query({ identifier }) + .matchHeader('authorization', `Bearer ${this.token}`) + .reply(200); + + await this.userBlocks.deleteByIdentifier({ identifier }); + expect(request.isDone()).to.be.true; + }); + }); +}); diff --git a/test/management/users.tests.js b/test/management/users.tests.js index 7d55bb7b1..9c0ab1dea 100644 --- a/test/management/users.tests.js +++ b/test/management/users.tests.js @@ -1,23 +1,31 @@ -var expect = require('chai').expect; -var nock = require('nock'); - -var SRC_DIR = '../../src'; -var API_URL = 'https://tenants.auth0.com'; - -var UsersManager = require(SRC_DIR + '/management/UsersManager'); -var ArgumentError = require('rest-facade').ArgumentError; - -describe('UsersManager', function() { - before(function() { - this.token = 'TOKEN'; - this.users = new UsersManager({ - headers: { authorization: 'Bearer ' + this.token }, - baseUrl: API_URL +const { expect } = require('chai'); +const nock = require('nock'); + +const API_URL = 'https://tenants.auth0.com'; + +const UsersManager = require(`../../src/management/UsersManager`); +const { ArgumentError } = require('rest-facade'); + +describe('UsersManager', () => { + /** + * @type {string} + */ + let token; + + /** + * @type {UsersManager} + */ + let usersManager; + before(() => { + token = 'TOKEN'; + usersManager = new UsersManager({ + headers: { authorization: `Bearer ${token}` }, + baseUrl: API_URL, }); }); - describe('instance', function() { - var methods = [ + describe('instance', () => { + const methods = [ 'get', 'getAll', 'create', @@ -31,1008 +39,1505 @@ describe('UsersManager', function() { 'updateUserMetadata', 'updateAppMetadata', 'getGuardianEnrollments', - 'regenerateRecoveryCode' + 'regenerateRecoveryCode', + 'invalidateRememberBrowser', + 'getRoles', + 'assignRoles', + 'removeRoles', + 'getPermissions', + 'assignPermissions', + 'removePermissions', + 'getUserOrganizations', ]; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { - expect(this.users[method]).to.exist.to.be.an.instanceOf(Function); + methods.forEach((method) => { + it(`should have a ${method} method`, () => { + expect(usersManager[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - describe('#constructor', function() { - it('should error when no options are provided', function() { - expect(UsersManager).to.throw(ArgumentError, 'Must provide manager options'); + describe('#constructor', () => { + it('should error when no options are provided', () => { + expect(() => { + new UsersManager(); + }).to.throw(ArgumentError, 'Must provide manager options'); }); - it('should throw an error when no base URL is provided', function() { - var manager = UsersManager.bind(null, {}); - - expect(manager).to.throw(ArgumentError, 'Must provide a base URL for the API'); + it('should throw an error when no base URL is provided', () => { + expect(() => { + new UsersManager({}); + }).to.throw(ArgumentError, 'Must provide a base URL for the API'); }); - it('should throw an error when the base URL is invalid', function() { - var manager = UsersManager.bind(null, { baseUrl: '' }); - - expect(manager).to.throw(ArgumentError, 'The provided base URL is invalid'); + it('should throw an error when the base URL is invalid', () => { + expect(() => { + new UsersManager({ baseUrl: '' }); + }).to.throw(ArgumentError, 'The provided base URL is invalid'); }); }); - describe('#getAll', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/users') - .reply(200); + describe('#getAll', () => { + /** + * @type {nock} + */ + let scope; + beforeEach(() => { + scope = nock(API_URL).get('/users').reply(200); }); - it('should accept a callback', function(done) { - this.users.getAll(function() { + it('should accept a callback', (done) => { + usersManager.getAll(() => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.users - .getAll() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', () => { + expect(usersManager.getAll()).instanceOf(Promise); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .get('/users') - .reply(500); + nock(API_URL).get('/users').reply(500); - this.users.getAll().catch(function(err) { + try { + await usersManager.getAll(); + } catch (err) { expect(err).to.exist; - - done(); - }); + } }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', async () => { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/users') - .reply(200, data); - - this.users.getAll().then(function(users) { - expect(users).to.be.an.instanceOf(Array); - - expect(users.length).to.equal(data.length); + const data = [{ test: true }]; + nock(API_URL).get('/users').reply(200, data); - expect(users[0].test).to.equal(data[0].test); - - done(); - }); + const users = await usersManager.getAll(); + expect(users).to.be.an.instanceOf(Array); + expect(users.length).to.equal(data.length); + expect(users[0].test).to.equal(data[0].test); }); - it('should perform a GET request to /api/v2/users', function(done) { - var request = this.request; - - this.users.getAll().then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + it('should perform a GET request to /api/v2/users', async () => { + await usersManager.getAll(); + expect(scope.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/users') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.users.getAll().then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await usersManager.getAll(); + expect(request.isDone()).to.be.true; }); - it('should pass the parameters in the query-string', function(done) { + it('should pass the parameters in the query-string', async () => { nock.cleanAll(); - var params = { + const params = { include_fields: true, - fields: 'test' + fields: 'test', }; - var request = nock(API_URL) - .get('/users') - .query(params) - .reply(200); - - this.users.getAll(params).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).get('/users').query(params).reply(200); - done(); - }); + await usersManager.getAll(params); + expect(request.isDone()).to.be.true; }); }); - describe('#getByEmail', function() { - beforeEach(function() { - this.request = nock(API_URL) - .get('/users-by-email') - .reply(200); + describe('#getByEmail', () => { + /** + * @type {nock} + */ + let scope; + beforeEach(() => { + scope = nock(API_URL).get('/users-by-email').reply(200); }); - it('should accept a callback', function(done) { - this.users.getByEmail('someone@example.com', function() { + it('should accept a callback', (done) => { + usersManager.getByEmail('someone@example.com', () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.users - .getByEmail() - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', () => { + expect(usersManager.getByEmail()).instanceOf(Promise); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .get('/users-by-email') - .reply(500); + nock(API_URL).get('/users-by-email').reply(500); - this.users.getByEmail().catch(function(err) { + try { + await usersManager.getByEmail(); + } catch (err) { expect(err).to.exist; - - done(); - }); + } }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should pass the body of the response to the "then" handler', async () => { nock.cleanAll(); - var data = [{ test: true }]; - var request = nock(API_URL) - .get('/users-by-email') - .reply(200, data); - - this.users.getByEmail().then(function(users) { - expect(users).to.be.an.instanceOf(Array); + const data = [{ test: true }]; + nock(API_URL).get('/users-by-email').reply(200, data); - expect(users.length).to.equal(data.length); - - expect(users[0].test).to.equal(data[0].test); - - done(); - }); + const users = await usersManager.getByEmail(); + expect(users).to.be.an.instanceOf(Array); + expect(users.length).to.equal(data.length); + expect(users[0].test).to.equal(data[0].test); }); - it('should perform a GET request to /api/v2/users-by-email', function(done) { - var request = this.request; - - this.users.getByEmail().then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + it('should perform a GET request to /api/v2/users-by-email', async () => { + await usersManager.getByEmail(); + expect(scope.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .get('/users-by-email') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.users.getByEmail().then(function() { - expect(request.isDone()).to.be.true; + await usersManager.getByEmail(); + expect(request.isDone()).to.be.true; + }); - done(); - }); + it('should pass an email in as a query string', async () => { + nock.cleanAll(); + + const params = { + email: 'email@example.com', + }; + const request = nock(API_URL).get('/users-by-email').query(params).reply(200); + + await usersManager.getByEmail(params.email); + expect(request.isDone()).to.be.true; }); - it('should pass an email in as a query string', function(done) { + it('should pass additional options into the query string', async () => { nock.cleanAll(); - var params = { - email: 'email@example.com' + const additionalOptions = { + fields: 'user_id, email, email_verified', + include_fields: true, + }; + const params = { + email: 'email@example.com', + ...additionalOptions, }; - var request = nock(API_URL) - .get('/users-by-email') - .query(params) - .reply(200); - this.users.getByEmail(params.email).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).get('/users-by-email').query(params).reply(200); - done(); - }); + await usersManager.getByEmail(params.email, additionalOptions); + expect(request.isDone()).to.be.true; }); }); - describe('#get', function() { - beforeEach(function() { - this.data = { + describe('#get', () => { + /** + * @typedef {object} data + * @property {number} id Id + * @property {string} name Name + * @property {boolean} enabled Enabled + * @property {string} script Script + * @property {string} stage Stage + */ + + /** + * @type {data} + */ + let data; + + /** + * @type {nock} + */ + let scope; + beforeEach(() => { + data = { id: 5, name: 'Test rule', enabled: true, script: "function (user, contest, callback) { console.log('Test'); }", - stage: 'login_success' + stage: 'login_success', }; - this.request = nock(API_URL) - .get('/users/' + this.data.id) - .reply(200, this.data); + scope = nock(API_URL).get(`/users/${data.id}`).reply(200, data); }); - it('should accept a callback', function(done) { - var params = { id: this.data.id }; + it('should accept a callback', (done) => { + const params = { id: data.id }; - this.users.get(params, done.bind(null, null)); + usersManager.get(params, done.bind(null, null)); }); - it('should return a promise if no callback is given', function(done) { - this.users - .get({ id: this.data.id }) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', () => { + expect(usersManager.get({ id: data.id })).instanceOf(Promise); }); - it('should perform a POST request to /api/v2/users/5', function(done) { - var request = this.request; - - this.users.get({ id: this.data.id }).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + it('should perform a POST request to /api/v2/users/5', async () => { + await usersManager.get({ id: data.id }); + expect(scope.isDone()).to.be.true; }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .get('/users/' + this.data.id) - .reply(500); + nock(API_URL).get(`/users/${data.id}`).reply(500); - this.users.get({ id: this.data.id }).catch(function(err) { + try { + await usersManager.get({ id: data.id }); + } catch (err) { expect(err).to.exist; - - done(); - }); + } }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) - .get('/users/' + this.data.id) - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .get(`/users/${data.id}`) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.users.get({ id: this.data.id }).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await usersManager.get({ id: data.id }); + expect(request.isDone()).to.be.true; }); }); - describe('#create', function() { - var data = { + describe('#create', () => { + const data = { id: 5, name: 'Test rule', enabled: true, script: "function (user, contest, callback) { console.log('Test'); }", - stage: 'login_success' + stage: 'login_success', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/users') - .reply(200); + /** + * @type {nock} + */ + let scope; + beforeEach(() => { + scope = nock(API_URL).post('/users').reply(200); }); - it('should accept a callback', function(done) { - this.users.create(data, function() { + it('should accept a callback', (done) => { + usersManager.create(data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.users - .create(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', () => { + expect(usersManager.create(data)).instanceOf(Promise); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .post('/users') - .reply(500); + nock(API_URL).post('/users').reply(500); - this.users.create(data).catch(function(err) { + try { + await usersManager.create(data); + } catch (err) { expect(err).to.exist; - - done(); - }); + } }); - it('should perform a POST request to /api/v2/users', function(done) { - var request = this.request; - - this.users.create(data).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + it('should perform a POST request to /api/v2/users', async () => { + await usersManager.create(data); + expect(scope.isDone()).to.be.true; }); - it('should pass the data in the body of the request', function(done) { + it('should pass the data in the body of the request', async () => { nock.cleanAll(); - var request = nock(API_URL) - .post('/users', data) - .reply(200); - - this.users.create(data).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).post('/users', data).reply(200); - done(); - }); + await usersManager.create(data); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .post('/users') - .matchHeader('Authorization', 'Bearer ' + this.token) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.users.create(data).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await usersManager.create(data); + expect(request.isDone()).to.be.true; }); }); - describe('#update', function() { - beforeEach(function() { - this.data = { id: 5 }; + describe('#update', () => { + /** + * @typedef {object} data + * @property {number} id Id + */ - this.request = nock(API_URL) - .patch('/users/' + this.data.id) - .reply(200, this.data); - }); + /** + * @type {data} + */ + let data; - it('should accept a callback', function(done) { - this.users.update({ id: 5 }, {}, done.bind(null, null)); - }); + /** + * @type {nock} + */ + let scope; + beforeEach(() => { + data = { id: 5 }; - it('should return a promise if no callback is given', function(done) { - this.users - .update({ id: 5 }, {}) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + scope = nock(API_URL).patch(`/users/${data.id}`).reply(200, data); }); - it('should perform a PATCH request to /api/v2/users/5', function(done) { - var request = this.request; + it('should accept a callback', (done) => { + usersManager.update({ id: 5 }, {}, done.bind(null, null)); + }); - this.users.update({ id: 5 }, {}).then(function() { - expect(request.isDone()).to.be.true; + it('should return a promise if no callback is given', () => { + expect(usersManager.update({ id: 5 }, {})).instanceOf(Promise); + }); - done(); - }); + it('should perform a PATCH request to /api/v2/users/5', async () => { + await usersManager.update({ id: 5 }, {}); + expect(scope.isDone()).to.be.true; }); - it('should include the new data in the body of the request', function(done) { + it('should include the new data in the body of the request', async () => { nock.cleanAll(); - var request = nock(API_URL) - .patch('/users/' + this.data.id, this.data) - .reply(200); + const request = nock(API_URL).patch(`/users/${data.id}`, data).reply(200); - this.users.update({ id: 5 }, this.data).then(function() { - expect(request.isDone()).to.be.true; + await usersManager.update({ id: 5 }, data); - done(); - }); + expect(request.isDone()).to.be.true; }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .patch('/users/' + this.data.id) - .reply(500); + nock(API_URL).patch(`/users/${data.id}`).reply(500); - this.users.update({ id: this.data.id }, this.data).catch(function(err) { + try { + await usersManager.update({ id: data.id }, data); + } catch (err) { expect(err).to.exist; - - done(); - }); + } }); }); - describe('#delete', function() { - var id = 'USER_5'; + describe('#delete', () => { + const id = 'USER_5'; - beforeEach(function() { - this.request = nock(API_URL) - .delete('/users/' + id) - .reply(200); - }); + /** + * @type {nock} + */ + let scope; - it('should accept a callback', function(done) { - this.users.delete({ id: id }, done.bind(null, null)); + beforeEach(() => { + scope = nock(API_URL).delete(`/users/${id}`).reply(200); }); - it('should return a promise when no callback is given', function(done) { - this.users.delete({ id: id }).then(done.bind(null, null)); + it('should accept a callback', (done) => { + usersManager.delete({ id }, done.bind(null, null)); }); - it('should perform a delete request to /users/' + id, function(done) { - var request = this.request; - - this.users.delete({ id: id }).then(function() { - expect(request.isDone()).to.be.true; + it('should return a promise when no callback is given', () => { + expect(usersManager.delete({ id })).instanceOf(Promise); + }); - done(); - }); + it(`should perform a delete request to /users/${id}`, async () => { + await usersManager.delete({ id }); + expect(scope.isDone()).to.be.true; }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .delete('/users/' + id) - .reply(500); + nock(API_URL).delete(`/users/${id}`).reply(500); - this.users.delete({ id: id }).catch(function(err) { + try { + await usersManager.delete({ id }); + } catch (err) { expect(err).to.exist; - - done(); - }); + } }); - it('should include the token in the authorization header', function(done) { + it('should include the token in the authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) - .delete('/users/' + id) - .matchHeader('authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .delete(`/users/${id}`) + .matchHeader('authorization', `Bearer ${token}`) .reply(200); - this.users.delete({ id: id }).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await usersManager.delete({ id }); + expect(request.isDone()).to.be.true; }); }); - describe('#link', function() { - var userId = 'USER_ID'; - var data = { + describe('#link', () => { + const userId = 'USER_ID'; + const data = { provider: 'twitter', - user_id: '191919191919191' + user_id: '191919191919191', }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/users/' + userId + '/identities') - .reply(200); + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL).post(`/users/${userId}/identities`).reply(200); }); - it('should validate empty userId', function() { - var _this = this; - expect(function() { - _this.users.link(null, data, function() {}); + it('should validate empty userId', () => { + expect(() => { + usersManager.link(null, data, () => {}); }).to.throw('The userId cannot be null or undefined'); }); - it('should validate non-string userId', function() { - var _this = this; - expect(function() { - _this.users.link(123, data, function() {}); + it('should validate non-string userId', () => { + expect(() => { + usersManager.link(123, data, () => {}); }).to.throw('The userId has to be a string'); }); - it('should accept a callback', function(done) { - this.users.link(userId, data, function() { + it('should accept a callback', (done) => { + usersManager.link(userId, data, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.users - .link(userId, data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', () => { + expect(usersManager.link(userId, data)).instanceOf(Promise); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .post('/users/' + userId + '/identities') - .reply(500); + nock(API_URL).post(`/users/${userId}/identities`).reply(500); - this.users.link(userId, data).catch(function(err) { + try { + await usersManager.link(userId, data); + } catch (err) { expect(err).to.exist; + } + }); - done(); - }); + it('should perform a POST request to /api/v2/users', async () => { + await usersManager.link(userId, data); + expect(scope.isDone()).to.be.true; }); - it('should perform a POST request to /api/v2/users', function(done) { - var request = this.request; + it('should pass the data in the body of the request', async () => { + nock.cleanAll(); - this.users.link(userId, data).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).post(`/users/${userId}/identities`, data).reply(200); - done(); - }); + await usersManager.link(userId, data); + expect(request.isDone()).to.be.true; }); - it('should pass the data in the body of the request', function(done) { + it('should include the token in the Authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) - .post('/users/' + userId + '/identities', data) + const request = nock(API_URL) + .post(`/users/${userId}/identities`) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.users.link(userId, data).then(function() { - expect(request.isDone()).to.be.true; + await usersManager.link(userId, data); + expect(request.isDone()).to.be.true; + }); + }); - done(); - }); + describe('#unlink', () => { + const data = { + id: 'u1', + user_id: 'u2', + provider: 'auth0', + }; + const url = `/users/${data.id}/identities/${data.provider}/${data.user_id}`; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL).delete(url).reply(200); + }); + + it('should accept a callback', (done) => { + usersManager.unlink(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', () => { + expect(usersManager.unlink(data)).instanceOf(Promise); }); - it('should include the token in the Authorization header', function(done) { + it(`should perform a DELETE request to ${url}`, async () => { + await usersManager.unlink(data); + expect(scope.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .post('/users/' + userId + '/identities') - .matchHeader('Authorization', 'Bearer ' + this.token) - .reply(200); + nock(API_URL).delete(url).reply(500); - this.users.link(userId, data).then(function() { - expect(request.isDone()).to.be.true; + try { + usersManager.unlink(data); + } catch (err) { + expect(err).to.exist; + } + }); - done(); - }); + it('should include the token in the authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .delete(url) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + await usersManager.unlink(data); + expect(request.isDone()).to.be.true; }); }); - describe('#unlink', function() { - var data = { + describe('#deleteMultifactorProvider', () => { + const data = { id: 'u1', - user_id: 'u2', - provider: 'auth0' + provider: 'auth0', }; - var url = '/users/' + data.id + '/identities/' + data.provider + '/' + data.user_id; + const url = `/users/${data.id}/multifactor/${data.provider}`; - beforeEach(function() { - this.request = nock(API_URL) - .delete(url) - .reply(200); + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL).delete(url).reply(200); }); - it('should accept a callback', function(done) { - this.users.unlink(data, done.bind(null, null)); + it('should accept a callback', (done) => { + usersManager.deleteMultifactorProvider(data, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { - this.users.unlink(data).then(done.bind(null, null)); + it('should return a promise when no callback is given', () => { + expect(usersManager.deleteMultifactorProvider(data)).instanceOf(Promise); }); - it('should perform a DELETE request to ' + url, function(done) { - var request = this.request; + it(`should perform a DELETE request to ${url}`, async () => { + await usersManager.deleteMultifactorProvider(data); + expect(scope.isDone()).to.be.true; + }); - this.users.unlink(data).then(function() { - expect(request.isDone()).to.be.true; + it('should pass any errors to the promise catch handler', async () => { + nock.cleanAll(); - done(); - }); + nock(API_URL).delete(url).reply(500); + + try { + await usersManager.deleteMultifactorProvider(data); + } catch (err) { + expect(err).to.exist; + } }); - it('should pass any errors to the promise catch handler', function(done) { + it('should include the token in the authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) + const request = nock(API_URL) .delete(url) - .reply(500); + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); - this.users.unlink(data).catch(function(err) { - expect(err).to.exist; + await usersManager.deleteMultifactorProvider(data); + expect(request.isDone()).to.be.true; + }); + }); - done(); - }); + describe('#updateUserMetadata', () => { + /** + * @typedef {object} data + * @property {number} id Id + * @property {string} foo Foo + * @property {string} test Test + */ + + /** + * @type {data} + */ + let data; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + data = { + id: 5, + foo: 'bar', + test: 'data', + }; + + scope = nock(API_URL).patch(`/users/${data.id}`).reply(200, data); + }); + + it('should accept a callback', (done) => { + usersManager.updateUserMetadata({ id: 5 }, {}, done.bind(null, null)); + }); + + it('should return a promise if no callback is given', () => { + expect(usersManager.updateUserMetadata({ id: 5 }, {})).instanceOf(Promise); + }); + + it('should perform a PATCH request to /api/v2/users/5', async () => { + await usersManager.updateUserMetadata({ id: 5 }, {}); + expect(scope.isDone()).to.be.true; }); - it('should include the token in the authorization header', function(done) { + it('should include the metadata in the body of the request', async () => { nock.cleanAll(); - var request = nock(API_URL) - .delete(url) - .matchHeader('authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .patch(`/users/${data.id}`, { + user_metadata: data, + }) .reply(200); - this.users.unlink(data).then(function() { - expect(request.isDone()).to.be.true; + await usersManager.updateUserMetadata({ id: 5 }, data); + expect(request.isDone()).to.be.true; + }); - done(); - }); + it('should pass any errors to the promise catch handler', async () => { + nock.cleanAll(); + + nock(API_URL).patch(`/users/${data.id}`).reply(500); + + try { + await usersManager.updateUserMetadata({ id: data.id }, data); + } catch (err) { + expect(err).to.exist; + } }); }); - describe('#deleteMultifactorProvider', function() { - var data = { - id: 'u1', - provider: 'auth0' + describe('#logs', () => { + const data = { + id: 'user_id', }; - var url = '/users/' + data.id + '/multifactor/' + data.provider; + const url = `/users/${data.id}/logs`; - beforeEach(function() { - this.request = nock(API_URL) - .delete(url) - .reply(200); + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL).get(url).reply(200); }); - it('should accept a callback', function(done) { - this.users.deleteMultifactorProvider(data, done.bind(null, null)); + it('should accept a callback', (done) => { + usersManager.logs(data, done.bind(null, null)); }); - it('should return a promise when no callback is given', function(done) { - this.users.deleteMultifactorProvider(data).then(done.bind(null, null)); + it('should return a promise when no callback is given', () => { + expect(usersManager.logs(data)).instanceOf(Promise); }); - it('should perform a DELETE request to ' + url, function(done) { - var request = this.request; + it(`should perform a GET request to ${url}`, async () => { + await usersManager.logs(data); + expect(scope.isDone()).to.be.true; + }); - this.users.deleteMultifactorProvider(data).then(function() { - expect(request.isDone()).to.be.true; + it('should pass any errors to the promise catch handler', async () => { + nock.cleanAll(); - done(); - }); + nock(API_URL).get(url).reply(500); + + try { + await usersManager.logs(data); + } catch (err) { + expect(err).to.exist; + } }); - it('should pass any errors to the promise catch handler', function(done) { + it('should include the token in the authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) - .delete(url) - .reply(500); + const request = nock(API_URL) + .get(url) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); - this.users.deleteMultifactorProvider(data).catch(function(err) { - expect(err).to.exist; + await usersManager.logs(data); + expect(request.isDone()).to.be.true; + }); - done(); - }); + it('should pass the body of the response to the "then" handler', async () => { + nock.cleanAll(); + + const response = [{ test: true }]; + nock(API_URL).get(url).reply(200, response); + + const logs = await usersManager.logs(data); + expect(logs).to.be.an.instanceOf(Array); + + expect(logs.length).to.equal(response.length); + + expect(logs[0].test).to.equal(response[0].test); }); - it('should include the token in the authorization header', function(done) { + it('should pass the parameters in the query-string', async () => { nock.cleanAll(); - var request = nock(API_URL) - .delete(url) - .matchHeader('authorization', 'Bearer ' + this.token) - .reply(200); + const params = { + page: 0, + per_page: 30, + }; + const request = nock(API_URL).get(url).query(params).reply(200); - this.users.deleteMultifactorProvider(data).then(function() { - expect(request.isDone()).to.be.true; + const ownData = { ...data }; + ownData.page = params.page; + ownData.per_page = params.per_page; - done(); - }); + await usersManager.logs(ownData); + expect(request.isDone()).to.be.true; }); }); - describe('#updateUserMetadata', function() { - beforeEach(function() { - this.data = { - id: 5, - foo: 'bar', - test: 'data' - }; + describe('#getGuardianEnrollments', () => { + const data = { + id: 5, + }; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL).get(`/users/${data.id}/enrollments`).reply(200); + }); + + it('should accept a callback', (done) => { + usersManager.getGuardianEnrollments(data, done.bind(null, null)); + }); - this.request = nock(API_URL) - .patch('/users/' + this.data.id) - .reply(200, this.data); + it('should return a promise when no callback is given', () => { + expect(usersManager.getGuardianEnrollments(data)).instanceOf(Promise); }); - it('should accept a callback', function(done) { - this.users.updateUserMetadata({ id: 5 }, {}, done.bind(null, null)); + it('should perform a GET request to /api/v2/users/5/enrollments', async () => { + await usersManager.getGuardianEnrollments(data); + expect(scope.isDone()).to.be.true; }); - it('should return a promise if no callback is given', function(done) { - this.users - .updateUserMetadata({ id: 5 }, {}) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should pass any errors to the promise catch handler', async () => { + nock.cleanAll(); + + nock(API_URL).get(`/users/${data.id}/enrollments`).reply(500); + + try { + await usersManager.getGuardianEnrollments(data); + } catch (err) { + expect(err).to.exist; + } + }); + + it('should include the token in the authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/users/${data.id}/enrollments`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + await usersManager.getGuardianEnrollments(data); + expect(request.isDone()).to.be.true; }); + }); + + describe('#regenerateRecoveryCode', () => { + const data = { + id: 'USER_ID', + }; - it('should perform a PATCH request to /api/v2/users/5', function(done) { - var request = this.request; + /** + * @type {nock} + */ + let scope; - this.users.updateUserMetadata({ id: 5 }, {}).then(function() { - expect(request.isDone()).to.be.true; + beforeEach(() => { + scope = nock(API_URL).post(`/users/${data.id}/recovery-code-regeneration`).reply(200); + }); + + it('should validate empty userId', () => { + expect(() => { + usersManager.regenerateRecoveryCode(null, () => {}); + }).to.throw('The userId cannot be null or undefined'); + }); + it('should accept a callback', (done) => { + usersManager.regenerateRecoveryCode(data, () => { done(); }); }); - it('should include the metadata in the body of the request', function(done) { + it('should return a promise if no callback is given', () => { + expect(usersManager.regenerateRecoveryCode(data)).instanceOf(Promise); + }); + + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .patch('/users/' + this.data.id, { - user_metadata: this.data - }) + nock(API_URL).post(`/users/${data.id}/recovery-code-regeneration`).reply(500); + + try { + await usersManager.regenerateRecoveryCode(data); + } catch (err) { + expect(err).to.exist; + } + }); + + it('should perform a POST request to /api/v2/users/:id/recovery-code-regeneration', async () => { + await usersManager.regenerateRecoveryCode(data); + expect(scope.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/users/${data.id}/recovery-code-regeneration`) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.users - .updateUserMetadata({ id: 5 }, this.data) - .then(function() { - expect(request.isDone()).to.be.true; + await usersManager.regenerateRecoveryCode(data); + expect(request.isDone()).to.be.true; + }); + }); - done(); - }) - .catch(done); + describe('#invalidateRememberBrowser', () => { + const data = { + id: 'USER_ID', + }; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL) + .post(`/users/${data.id}/multifactor/actions/invalidate-remember-browser`) + .reply(204); + }); + + it('should validate empty userId', () => { + expect(() => { + usersManager.invalidateRememberBrowser(null, () => {}); + }).to.throw('The userId cannot be null or undefined'); + }); + + it('should accept a callback', (done) => { + usersManager.invalidateRememberBrowser(data, () => { + done(); + }); + }); + + it('should return a promise if no callback is given', () => { + expect(usersManager.invalidateRememberBrowser(data)).instanceOf(Promise); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .patch('/users/' + this.data.id) + nock(API_URL) + .post(`/users/${data.id}/multifactor/actions/invalidate-remember-browser`) .reply(500); - this.users.updateUserMetadata({ id: this.data.id }, this.data).catch(function(err) { + try { + await usersManager.invalidateRememberBrowser(data); + } catch (err) { expect(err).to.exist; + } + }); - done(); - }); + it('should perform a POST request to /api/v2/users/:id/multifactor/actions/invalidate-remember-browser', async () => { + await usersManager.invalidateRememberBrowser(data); + expect(scope.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/users/${data.id}/multifactor/actions/invalidate-remember-browser`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + await usersManager.invalidateRememberBrowser(data); + expect(request.isDone()).to.be.true; }); }); - describe('#logs', function() { - var data = { - id: 'user_id' + describe('#getRoles', () => { + const data = { + id: 'user_id', }; - var url = '/users/' + data.id + '/logs'; - beforeEach(function() { - this.request = nock(API_URL) - .get(url) - .reply(200); + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL).get(`/users/${data.id}/roles`).reply(200); + }); + + it('should accept a callback', (done) => { + usersManager.getRoles(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', () => { + expect(usersManager.getRoles(data)).instanceOf(Promise); + }); + + it('should perform a GET request to /api/v2/users/user_id/roles', async () => { + await usersManager.getRoles(data); + expect(scope.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', async () => { + nock.cleanAll(); + + nock(API_URL).get(`/users/${data.id}/roles`).reply(500); + + try { + await usersManager.getRoles(data); + } catch (err) { + expect(err).to.exist; + } }); - it('should accept a callback', function(done) { - this.users.logs(data, done.bind(null, null)); + it('should include the token in the authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/users/${data.id}/roles`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + await usersManager.getRoles(data); + expect(request.isDone()).to.be.true; }); + }); - it('should return a promise when no callback is given', function(done) { - this.users.logs(data).then(done.bind(null, null)); + describe('#assignRoles', () => { + /** + * @typedef {object} data + * @property {string} id Id + */ + + /** + * @typedef {object} body + * @property {Array} roles Roles + */ + + /** + * @type {data} + */ + let data; + + /** + * @type {body} + */ + let body; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + data = { + id: 'user_id', + }; + body = { roles: ['role1', 'role2', 'role3'] }; + + scope = nock(API_URL).post(`/users/${data.id}/roles`).reply(200); }); - it('should perform a GET request to ' + url, function(done) { - var request = this.request; + it('should validate empty user_id', () => { + expect(() => { + usersManager.assignRoles({ id: null }, body, () => {}); + }).to.throw('The user_id cannot be null or undefined'); + }); - this.users.logs(data).then(function() { - expect(request.isDone()).to.be.true; + it('should validate non-string user_id', () => { + expect(() => { + usersManager.assignRoles({ id: 127 }, body, () => {}); + }).to.throw('The user_id has to be a string'); + }); + it('should accept a callback', (done) => { + usersManager.assignRoles(data, {}, () => { done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should return a promise if no callback is given', () => { + expect(usersManager.assignRoles(data, {})).instanceOf(Promise); + }); + + it('should pass any errors to the promise catch handler', () => { nock.cleanAll(); - var request = nock(API_URL) - .get(url) - .reply(500); + nock(API_URL).post(`/users/${data.id}/roles`).reply(500); - this.users.logs(data).catch(function(err) { + try { + usersManager.assignRoles(data, {}); + } catch (err) { expect(err).to.exist; + } + }); - done(); - }); + it('should perform a POST request to /api/v2/users/user_id/roles', async () => { + await usersManager.assignRoles(data, {}); + expect(scope.isDone()).to.be.true; }); - it('should include the token in the authorization header', function(done) { + it('should pass the data in the body of the request', async () => { nock.cleanAll(); - var request = nock(API_URL) - .get(url) - .matchHeader('authorization', 'Bearer ' + this.token) + const request = nock(API_URL).post(`/users/${data.id}/roles`, body).reply(200); + + await usersManager.assignRoles(data, body); + expect(request.isDone()).to.be.true; + }); + + it('should include the token in the Authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/users/${data.id}/roles`) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.users.logs(data).then(function() { - expect(request.isDone()).to.be.true; + await usersManager.assignRoles(data, {}); + expect(request.isDone()).to.be.true; + }); + }); + + describe('#removeRoles', () => { + /** + * @typedef {object} data + * @property {string} id Id + */ + + /** + * @typedef {object} body + * @property {Array} roles Roles + */ + + /** + * @type {data} + */ + let data; + + /** + * @type {body} + */ + let body; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + data = { + id: 'user_id', + }; + body = { roles: ['role1', 'role2', 'role3'] }; + + scope = nock(API_URL).delete(`/users/${data.id}/roles`, {}).reply(200); + }); + it('should validate empty user_id', () => { + expect(() => { + usersManager.removeRoles({ id: null }, body, () => {}); + }).to.throw('The user_id cannot be null or undefined'); + }); + + it('should validate non-string user_id', () => { + expect(() => { + usersManager.removeRoles({ id: 123 }, body, () => {}); + }).to.throw('The user_id has to be a string'); + }); + + it('should accept a callback', (done) => { + usersManager.removeRoles(data, {}, () => { done(); }); }); - it('should pass the body of the response to the "then" handler', function(done) { + it('should return a promise if no callback is given', () => { + expect(usersManager.removeRoles(data, {})).instanceOf(Promise); + }); + + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var response = [{ test: true }]; - var request = nock(API_URL) - .get(url) - .reply(200, response); + nock(API_URL).post(`/users/${data.id}/roles`).reply(500); - this.users.logs(data).then(function(logs) { - expect(logs).to.be.an.instanceOf(Array); + try { + await usersManager.removeRoles(data, {}); + } catch (err) { + expect(err).to.exist; + } + }); - expect(logs.length).to.equal(response.length); + it('should perform a DELETE request to /api/v2/users/user_id/roles', async () => { + await usersManager.removeRoles(data, {}); + expect(scope.isDone()).to.be.true; + }); - expect(logs[0].test).to.equal(response[0].test); + it('should pass the data in the body of the request', async () => { + nock.cleanAll(); - done(); - }); + const request = nock(API_URL).delete(`/users/${data.id}/roles`, body).reply(200); + + await usersManager.removeRoles(data, body); + expect(request.isDone()).to.be.true; }); - it('should pass the parameters in the query-string', function(done) { + it('should include the token in the Authorization header', async () => { nock.cleanAll(); - var params = { - page: 0, - per_page: 30 - }; - var request = nock(API_URL) - .get(url) - .query(params) + const request = nock(API_URL) + .delete(`/users/${data.id}/roles`) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - data.page = params.page; - data.per_page = params.per_page; - - this.users.logs(data).then(function() { - expect(request.isDone()).to.be.true; - - done(); - }); + await usersManager.removeRoles(data, {}); + expect(request.isDone()).to.be.true; }); }); - describe('#getGuardianEnrollments', function() { - var data = { - id: 5 + describe('#getPermissions', () => { + const data = { + id: 'user_id', }; - beforeEach(function() { - this.request = nock(API_URL) - .get('/users/' + data.id + '/enrollments') - .reply(200); + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL).get(`/users/${data.id}/permissions`).reply(200); + }); + + it('should accept a callback', (done) => { + usersManager.getPermissions(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', () => { + expect(usersManager.getPermissions(data)).instanceOf(Promise); + }); + + it('should perform a GET request to /api/v2/users/user_id/permissions', async () => { + await usersManager.getPermissions(data); + expect(scope.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', async () => { + nock.cleanAll(); + + nock(API_URL).get(`/users/${data.id}/permissions`).reply(500); + + try { + usersManager.getPermissions(data); + } catch (err) { + expect(err).to.exist; + } }); - it('should accept a callback', function(done) { - this.users.getGuardianEnrollments(data, done.bind(null, null)); + it('should include the token in the authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/users/${data.id}/permissions`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + await usersManager.getPermissions(data); + expect(request.isDone()).to.be.true; }); + }); + + describe('#assignPermissions', () => { + /** + * @typedef {object} data + * @property {string} id Id + */ + + /** + * @typedef {object} body + * @property {string} permission_name Permission name + * @property {string} resource_server_identifier Resource server identifier + */ + + /** + * @type {data} + */ + let data; + + /** + * @type {body} + */ + let body; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + data = { + id: 'user_id', + }; + body = { permission_name: 'My Permission', resource_server_identifier: 'test123' }; - it('should return a promise when no callback is given', function(done) { - this.users.getGuardianEnrollments(data).then(done.bind(null, null)); + scope = nock(API_URL).post(`/users/${data.id}/permissions`).reply(200); }); - it('should perform a GET request to /api/v2/users/5/enrollments', function(done) { - var request = this.request; + it('should validate empty user_id', () => { + expect(() => { + usersManager.assignPermissions({ id: null }, body, () => {}); + }).to.throw('The user_id cannot be null or undefined'); + }); - this.users.getGuardianEnrollments(data).then(function() { - expect(request.isDone()).to.be.true; + it('should validate non-string user_id', () => { + expect(() => { + usersManager.assignPermissions({ id: 123 }, body, () => {}); + }).to.throw('The user_id has to be a string'); + }); + it('should accept a callback', (done) => { + usersManager.assignPermissions(data, {}, () => { done(); }); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should return a promise if no callback is given', () => { + expect(usersManager.assignPermissions(data, {})).instanceOf(Promise); + }); + + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .get('/users/' + data.id + '/enrollments') - .reply(500); + nock(API_URL).post(`/users/${data.id}/permissions`).reply(500); - this.users.getGuardianEnrollments(data).catch(function(err) { + try { + await usersManager.assignPermissions(data, {}); + } catch (err) { expect(err).to.exist; + } + }); - done(); - }); + it('should perform a POST request to /api/v2/users/user_id/permissions', async () => { + await usersManager.assignPermissions(data, {}); + expect(scope.isDone()).to.be.true; }); - it('should include the token in the authorization header', function(done) { + it('should pass the data in the body of the request', async () => { nock.cleanAll(); - var request = nock(API_URL) - .get('/users/' + data.id + '/enrollments') - .matchHeader('authorization', 'Bearer ' + this.token) - .reply(200); + const request = nock(API_URL).post(`/users/${data.id}/permissions`, body).reply(200); - this.users.getGuardianEnrollments(data).then(function() { - expect(request.isDone()).to.be.true; + await usersManager.assignPermissions(data, body); + expect(request.isDone()).to.be.true; + }); - done(); - }); + it('should include the token in the Authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .post(`/users/${data.id}/permissions`) + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200); + + await usersManager.assignPermissions(data, {}); + expect(request.isDone()).to.be.true; }); }); - describe('#regenerateRecoveryCode', function() { - var data = { - id: 'USER_ID' - }; + describe('#removePermissions', () => { + /** + * @typedef {object} data + * @property {string} id Id + */ + + /** + * @typedef {object} body + * @property {string} permission_name Permission name + * @property {string} resource_server_identifier Resource server identifier + */ + + /** + * @type {data} + */ + let data; + + /** + * @type {body} + */ + let body; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + data = { + id: 'user_id', + }; + body = { permission_name: 'My Permission', resource_server_identifier: 'test123' }; - beforeEach(function() { - this.request = nock(API_URL) - .post('/users/' + data.id + '/recovery-code-regeneration') - .reply(200); + scope = nock(API_URL).delete(`/users/${data.id}/permissions`, {}).reply(200); }); - it('should validate empty userId', function() { - var _this = this; - expect(function() { - _this.users.regenerateRecoveryCode(null, function() {}); - }).to.throw('The userId cannot be null or undefined'); + it('should validate empty user_id', () => { + expect(() => { + usersManager.removePermissions({ id: null }, body, () => {}); + }).to.throw('The user_id cannot be null or undefined'); }); - it('should accept a callback', function(done) { - this.users.regenerateRecoveryCode(data, function() { + it('should validate non-string user_id', () => { + expect(() => { + usersManager.removePermissions({ id: 123 }, body, () => {}); + }).to.throw('The user_id has to be a string'); + }); + + it('should accept a callback', (done) => { + usersManager.removePermissions(data, {}, () => { done(); }); }); - it('should return a promise if no callback is given', function(done) { - this.users - .regenerateRecoveryCode(data) - .then(done.bind(null, null)) - .catch(done.bind(null, null)); + it('should return a promise if no callback is given', () => { + expect(usersManager.removePermissions(data, {})).instanceOf(Promise); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass any errors to the promise catch handler', async () => { nock.cleanAll(); - var request = nock(API_URL) - .post('/users/' + data.id + '/recovery-code-regeneration') - .reply(500); + nock(API_URL).post(`/users/${data.id}/permissions`).reply(500); - this.users.regenerateRecoveryCode(data).catch(function(err) { + try { + await usersManager.removePermissions(data, {}); + } catch (err) { expect(err).to.exist; + } + }); - done(); - }); + it('should perform a DELETE request to /api/v2/users/user_id/permissions', async () => { + await usersManager.removePermissions(data, {}); + expect(scope.isDone()).to.be.true; }); - it('should perform a POST request to /api/v2/users/:id/recovery-code-regeneration', function(done) { - var request = this.request; + it('should pass the data in the body of the request', async () => { + nock.cleanAll(); - this.users.regenerateRecoveryCode(data).then(function() { - expect(request.isDone()).to.be.true; + const request = nock(API_URL).delete(`/users/${data.id}/permissions`, body).reply(200); - done(); - }); + await usersManager.removePermissions(data, body); + expect(request.isDone()).to.be.true; }); - it('should include the token in the Authorization header', function(done) { + it('should include the token in the Authorization header', async () => { nock.cleanAll(); - var request = nock(API_URL) - .post('/users/' + data.id + '/recovery-code-regeneration') - .matchHeader('Authorization', 'Bearer ' + this.token) + const request = nock(API_URL) + .delete(`/users/${data.id}/permissions`) + .matchHeader('Authorization', `Bearer ${token}`) .reply(200); - this.users.regenerateRecoveryCode(data).then(function() { - expect(request.isDone()).to.be.true; + await usersManager.removePermissions(data, {}); + expect(request.isDone()).to.be.true; + }); + }); - done(); - }); + describe('#getUserOrganizations', () => { + const data = { + id: 'user_id', + }; + + /** + * @type {nock} + */ + let scope; + + beforeEach(() => { + scope = nock(API_URL).get(`/users/${data.id}/organizations`).reply(200); + }); + + it('should accept a callback', (done) => { + usersManager.getUserOrganizations(data, done.bind(null, null)); + }); + + it('should return a promise when no callback is given', () => { + expect(usersManager.getUserOrganizations(data)).instanceOf(Promise); + }); + + it('should perform a GET request to /api/v2/users/user_id/organizations', async () => { + await usersManager.getUserOrganizations(data); + expect(scope.isDone()).to.be.true; + }); + + it('should pass any errors to the promise catch handler', async () => { + nock.cleanAll(); + + nock(API_URL).get(`/users/${data.id}/organizations`).reply(500); + + try { + await usersManager.getUserOrganizations(data); + } catch (err) { + expect(err).to.exist; + } + }); + + it('should include the token in the authorization header', async () => { + nock.cleanAll(); + + const request = nock(API_URL) + .get(`/users/${data.id}/organizations`) + .matchHeader('authorization', `Bearer ${token}`) + .reply(200); + + await usersManager.getUserOrganizations(data); + expect(request.isDone()).to.be.true; }); }); }); diff --git a/test/retry-rest-client.tests.js b/test/retry-rest-client.tests.js index e6e7ec366..75a93ebf6 100644 --- a/test/retry-rest-client.tests.js +++ b/test/retry-rest-client.tests.js @@ -1,370 +1,293 @@ -var expect = require('chai').expect; -var nock = require('nock'); - -var Promise = require('bluebird'); -var ArgumentError = require('rest-facade').ArgumentError; -var RestClient = require('rest-facade').Client; -var RetryRestClient = require('../src/RetryRestClient'); - -var API_URL = 'https://tenant.auth0.com'; - -describe('RetryRestClient', function() { - before(function() { - this.restClient = new RestClient(API_URL); +const { expect } = require('chai'); +const sinon = require('sinon'); +const nock = require('nock'); + +const { ArgumentError } = require('rest-facade'); +const RestClient = require('rest-facade').Client; +const RetryRestClient = require('../src/RetryRestClient'); + +const API_URL = 'https://tenant.auth0.com'; + +Promise.prototype.finally = + Promise.prototype.finally || + function (fn) { + const onFinally = (callback) => Promise.resolve(fn()).then(callback); + return this.then( + (result) => onFinally(() => result), + (reason) => onFinally(() => Promise.reject(reason)) + ); + }; + +describe('RetryRestClient', () => { + let restClient; + before(() => { + restClient = new RestClient(API_URL); }); - it('should raise an error when no RestClient is provided', function() { - expect(RetryRestClient).to.throw(ArgumentError, 'Must provide RestClient'); + it('should raise an error when no RestClient is provided', () => { + expect(() => { + new RetryRestClient(); + }).to.throw(ArgumentError, 'Must provide RestClient'); }); - it('should raise an error when enabled is not of type boolean', function() { - var options = { enabled: {} }; - var client = RetryRestClient.bind(null, {}, options); - expect(client).to.throw(ArgumentError, 'Must provide enabled boolean value'); + it('should raise an error when enabled is not of type boolean', () => { + const options = { enabled: {} }; + expect(() => { + new RetryRestClient({}, options); + }).to.throw(ArgumentError, 'Must provide enabled boolean value'); }); - it('should raise an error when maxRetries is negative', function() { - var options = { maxRetries: -1 }; - var client = RetryRestClient.bind(null, {}, options); - expect(client).to.throw(ArgumentError, 'Must provide maxRetries as a positive number'); + it('should raise an error when maxRetries is negative', () => { + const options = { maxRetries: -1 }; + expect(() => { + new RetryRestClient({}, options); + }).to.throw(ArgumentError, 'Must provide maxRetries as a positive number'); }); - describe('instance', function() { - var client = new RetryRestClient(new RestClient(API_URL)); - var methods = ['getAll', 'get', 'create', 'update', 'delete']; + describe('instance', () => { + const client = new RetryRestClient(new RestClient(API_URL)); + const methods = ['getAll', 'get', 'create', 'update', 'delete']; - methods.forEach(function(method) { - it('should have a ' + method + ' method', function() { + methods.forEach((method) => { + it(`should have a ${method} method`, () => { expect(client[method]).to.exist.to.be.an.instanceOf(Function); }); }); }); - it('should pass data to callback when provided', function(done) { - nock(API_URL) - .get('/') - .reply(200, { success: true }); + it('should pass data to callback when provided', (done) => { + nock(API_URL).get('/').reply(200, { success: true }); - var client = new RetryRestClient(this.restClient); - client.getAll(function(err, data) { + const client = new RetryRestClient(restClient); + client.getAll((err, data) => { expect(err).to.null; expect(data.success).to.be.true; done(); }); }); - it('should return promise for successful request when no callback is provided', function(done) { - nock(API_URL) - .get('/') - .reply(200, { success: true }); + it('should return promise for successful request when no callback is provided', async () => { + nock(API_URL).get('/').reply(200, { success: true }); - var client = new RetryRestClient(this.restClient); - client.getAll().then(function(data) { - expect(data.success).to.be.true; - done(); - }); + const client = new RetryRestClient(restClient); + const data = await client.getAll(); + expect(data.success).to.be.true; }); - it('should pass err to callback when provided', function(done) { - nock(API_URL) - .get('/') - .reply(500); + it('should pass err to callback when provided', (done) => { + nock(API_URL).get('/').reply(500); - var client = new RetryRestClient(this.restClient); - client.getAll(function(err) { + const client = new RetryRestClient(restClient); + client.getAll((err) => { expect(err).to.not.null; expect(err.statusCode).to.be.equal(500); done(); }); }); - it('should return promise for failed request when no callback is provided', function(done) { - nock(API_URL) - .get('/') - .reply(500); + it('should return promise for failed request when no callback is provided', async () => { + nock(API_URL).get('/').reply(500); - var client = new RetryRestClient(this.restClient); - client.getAll().catch(function(err) { + const client = new RetryRestClient(restClient); + try { + await client.getAll(); + } catch (err) { expect(err).to.not.null; expect(err.statusCode).to.be.equal(500); - done(); - }); + } }); - it('should retry once when an error is returned', function(done) { - var self = this; - var timesCalled = 0; - var restClientSpy = { - getAll: function() { + it('should retry once when an error is returned', async () => { + let timesCalled = 0; + const restClientSpy = { + getAll(...args) { timesCalled += 1; - return self.restClient.getAll(arguments); - } + return restClient.getAll(args); + }, }; - nock(API_URL) - .get('/') - .reply( - 429, - { success: false }, - { - 'x-ratelimit-limit': '10', - 'x-ratelimit-remaining': '0', - 'x-ratelimit-reset': '1508253300' - } - ) - .get('/') - .reply(200, { success: true }); + nock(API_URL).get('/').reply(429, { success: false }).get('/').reply(200, { success: true }); - var client = new RetryRestClient(restClientSpy); - client.getAll().then(function(data) { - expect(data.success).to.be.true; - expect(timesCalled).to.be.equal(2); - done(); - }); + const client = new RetryRestClient(restClientSpy); + const data = await client.getAll(); + expect(data.success).to.be.true; + expect(timesCalled).to.be.equal(2); }); - it('should try 4 times when request fails 3 times', function(done) { - var self = this; - var timesCalled = 0; - var restClientSpy = { - getAll: function() { + it('should try 4 times when request fails 3 times', async () => { + const clock = sinon.useFakeTimers(); + let timesCalled = 0; + const restClientSpy = { + getAll(...args) { timesCalled += 1; - return self.restClient.getAll(arguments); - } + return restClient.getAll(...args).finally(() => { + clock.runAllAsync(); + }); + }, }; nock(API_URL) .get('/') .times(3) - .reply( - 429, - { success: false }, - { - 'x-ratelimit-limit': '10', - 'x-ratelimit-remaining': '0', - 'x-ratelimit-reset': '1508253300' - } - ) + .reply(429, { success: false }) .get('/') .reply(200, { success: true }); - var client = new RetryRestClient(restClientSpy); - client.getAll().then(function(data) { - expect(data.success).to.be.true; - expect(timesCalled).to.be.equal(4); - done(); - }); + const client = new RetryRestClient(restClientSpy); + const data = await client.getAll(); + clock.restore(); + expect(data.success).to.be.true; + expect(timesCalled).to.be.equal(4); }); - it('should retry 2 times and fail when maxRetries is exceeded with no delay time', function(done) { - var self = this; - var timesCalled = 0; - var restClientSpy = { - getAll: function() { + it('should retry 2 times and fail when maxRetries is exceeded', async () => { + const clock = sinon.useFakeTimers(); + let timesCalled = 0; + const restClientSpy = { + getAll(...args) { timesCalled += 1; - return self.restClient.getAll(arguments); - } + return restClient.getAll(...args).finally(() => { + clock.runAllAsync(); + }); + }, }; - nock(API_URL) - .get('/') - .times(4) - .reply( - 429, - { success: false }, - { - 'x-ratelimit-limit': '10', - 'x-ratelimit-remaining': '0', - 'x-ratelimit-reset': (new Date().getTime() - 10) / 1000 // past. - } - ); + nock(API_URL).get('/').times(4).reply(429, { success: false }); - var client = new RetryRestClient(restClientSpy, { maxRetries: 3 }); - client.getAll().catch(function(err) { + const client = new RetryRestClient(restClientSpy, { maxRetries: 3 }); + try { + await client.getAll(); + } catch (err) { + clock.restore(); expect(err).to.not.null; expect(timesCalled).to.be.equal(4); // Initial call + 3 retires. - done(); - }); + } }); - it('should retry 2 times and fail when maxRetries is exceeded with delay time', function(done) { - var self = this; - var timesCalled = 0; - var restClientSpy = { - getAll: function() { - timesCalled += 1; - return self.restClient.getAll(arguments); - } - }; + it('should not retry when status code is not 429', async () => { + nock(API_URL).get('/').reply(500); - nock(API_URL) - .get('/') - .reply( - 429, - { success: false }, - { - 'x-ratelimit-limit': '10', - 'x-ratelimit-remaining': '0', - 'x-ratelimit-reset': (new Date().getTime() + 50) / 1000 // epoch seconds + 50ms - } - ) - .get('/') - .reply( - 429, - { success: false }, - { - 'x-ratelimit-limit': '10', - 'x-ratelimit-remaining': '0', - 'x-ratelimit-reset': (new Date().getTime() + 100) / 1000 // epoch seconds + 100ms - } - ); - - var client = new RetryRestClient(restClientSpy, { maxRetries: 1 }); - client.getAll().catch(function(err) { - expect(err).to.not.null; - expect(timesCalled).to.be.equal(2); // Initial call + 3 retires. - done(); - }); - }); - - it('should not retry when status code is not 429', function(done) { - nock(API_URL) - .get('/') - .reply(500); - - var client = new RetryRestClient(this.restClient); - client.getAll().catch(function(err) { + const client = new RetryRestClient(restClient); + try { + await client.getAll(); + } catch (err) { expect(err).to.not.null; expect(err.statusCode).to.be.equal(500); - done(); - }); + } }); - it('should delay the retry using x-ratelimit-reset header value and succeed after retry', function(done) { - var self = this; - var calledAt = []; - var restClientSpy = { - getAll: function() { - calledAt.push(new Date().getTime()); - return self.restClient.getAll(arguments); - } + it('should delay the retry using exponential backoff and succeed after retry', async () => { + const clock = sinon.useFakeTimers(); + const backoffs = []; + let prev = 0; + const restClientSpy = { + getAll(...args) { + const now = new Date().getTime(); + backoffs.push(now - prev); + prev = now; + return restClient.getAll(...args).finally(() => { + clock.runAllAsync(); + }); + }, }; nock(API_URL) .get('/') - .reply( - 429, - { success: false }, - { - 'x-ratelimit-limit': '10', - 'x-ratelimit-remaining': '0', - 'x-ratelimit-reset': (new Date().getTime() + 50) / 1000 // epoch seconds + 50ms - } - ) + .times(9) + .reply(429, { success: false }) .get('/') .reply(200, { success: true }); - var client = new RetryRestClient(restClientSpy); + const client = new RetryRestClient(restClientSpy, { maxRetries: 10 }); - client.getAll().then(function(data) { - expect(data.success).to.be.true; - expect(calledAt.length).to.be.equal(2); + const data = await client.getAll(); + clock.restore(); + expect(data.success).to.be.true; + expect(backoffs.length).to.be.equal(10); - var elapsedTime = calledAt[1] - calledAt[0]; - expect(elapsedTime).to.be.above(49); // Time between the requests should at least be more than 49ms - done(); - }); + expect(backoffs.shift()).to.be.equal(0, 'first request should happen immediately'); + for (let i = 0; i < backoffs.length; i++) { + expect(backoffs[i] / 1000).to.be.within( + Math.pow(2, i), + 2 * Math.pow(2, i), + `attempt ${i + 1} in secs` + ); + } }); - it('should not retry when retry functionality is disabled', function(done) { - var self = this; - var timesCalled = 0; - var restClientSpy = { - getAll: function() { + it('should not retry when retry functionality is disabled', async () => { + let timesCalled = 0; + const restClientSpy = { + getAll(...args) { timesCalled += 1; - return self.restClient.getAll(arguments); - } + return restClient.getAll(...args); + }, }; - nock(API_URL) - .get('/') - .reply( - 429, - { success: false }, - { - 'x-ratelimit-limit': '10', - 'x-ratelimit-remaining': '0', - 'x-ratelimit-reset': '1508253300' - } - ); + nock(API_URL).get('/').reply(429, { success: false }); - var client = new RetryRestClient(restClientSpy, { enabled: false }); - client.getAll().catch(function(err) { + const client = new RetryRestClient(restClientSpy, { enabled: false }); + try { + await client.getAll(); + } catch (err) { expect(err).to.not.null; expect(err.statusCode).to.be.equal(429); expect(timesCalled).to.be.equal(1); - done(); - }); + } }); - it('should remove callback from arguments object if data is passed', function(done) { - var self = this; - var restClientSpy = { - create: function() { + it('should remove callback from arguments object if data is passed', (done) => { + const restClientSpy = { + create() { expect(arguments.length).to.be.equal(1); done(); return Promise.resolve(); - } + }, }; - var client = new RetryRestClient(restClientSpy, { enabled: false }); - client.create({ data: 'foobar' }, function() {}); + const client = new RetryRestClient(restClientSpy, { enabled: false }); + client.create({ data: 'foobar' }, () => {}); }); - it('should remove callback from arguments object if urlParams and data is passed', function(done) { - var self = this; - var restClientSpy = { - create: function() { + it('should remove callback from arguments object if urlParams and data is passed', (done) => { + const restClientSpy = { + create() { expect(arguments.length).to.be.equal(2); done(); return Promise.resolve(); - } + }, }; - var client = new RetryRestClient(restClientSpy, { enabled: false }); - var urlParams = { id: '123' }; - var data = { data: 'foobar' }; - client.create('/:id', data, function() {}); + const client = new RetryRestClient(restClientSpy, { enabled: false }); + const data = { data: 'foobar' }; + client.create('/:id', data, () => {}); }); - it('should not remove data object when no callback is passed', function(done) { - var self = this; - var restClientSpy = { - create: function() { + it('should not remove data object when no callback is passed', (done) => { + const restClientSpy = { + create() { expect(arguments.length).to.be.equal(1); done(); return Promise.resolve(); - } + }, }; - var client = new RetryRestClient(restClientSpy, { enabled: false }); - var data = { data: 'foobar' }; + const client = new RetryRestClient(restClientSpy, { enabled: false }); + const data = { data: 'foobar' }; client.create(data); }); - it('should not remove data object when urlParams is passed and no callback is passed', function(done) { - var self = this; - var restClientSpy = { - create: function() { + it('should not remove data object when urlParams is passed and no callback is passed', (done) => { + const restClientSpy = { + create() { expect(arguments.length).to.be.equal(2); done(); return Promise.resolve(); - } + }, }; - var client = new RetryRestClient(restClientSpy, { enabled: false }); - var urlParams = { id: '123' }; - var data = { data: 'foobar' }; + const client = new RetryRestClient(restClientSpy, { enabled: false }); + const data = { data: 'foobar' }; client.create('/:id', data); }); }); diff --git a/test/utils.tests.js b/test/utils.tests.js new file mode 100644 index 000000000..c733653a9 --- /dev/null +++ b/test/utils.tests.js @@ -0,0 +1,34 @@ +const { expect } = require('chai'); +const utils = require('../src/utils.js'); + +describe('Utils', () => { + describe('client info', () => { + it('should generate default telemetry value', () => { + const pkgVersion = require('../package.json').version; + const nodeVersion = process.version.replace('v', ''); + expect(utils.generateClientInfo()).to.deep.equal({ + name: 'node-auth0', + version: pkgVersion, + env: { node: nodeVersion }, + }); + }); + }); + describe('maybe decode', () => { + it('encodes regular user_id', () => { + const normalId = 'auth0|1234'; + expect(utils.maybeDecode(normalId)).to.be.equal('auth0%7C1234'); + }); + it('encodes a malicious user_id', () => { + const maliciousId = 'anotherUserId/secret'; + expect(utils.maybeDecode(maliciousId)).to.be.equal('anotherUserId%2Fsecret'); + }); + it('encodes a malicious user_id with a percentage', () => { + const maliciousId = 'anotherUserId/secret%23'; + expect(utils.maybeDecode(maliciousId)).to.be.equal('anotherUserId%2Fsecret%2523'); + }); + it('does not encode an already encoded user_id', () => { + const maliciousId = 'auth0%7C1234'; + expect(utils.maybeDecode(maliciousId)).to.be.equal('auth0%7C1234'); + }); + }); +}); diff --git a/test/utils/ensureMethod.js b/test/utils/ensureMethod.js index 1efd07cec..56ecc6c4a 100644 --- a/test/utils/ensureMethod.js +++ b/test/utils/ensureMethod.js @@ -1,7 +1,7 @@ -var expect = require('chai').expect; +const { expect } = require('chai'); -module.exports = function(obj, name) { - return function() { +module.exports = function (obj, name) { + return function () { expect(obj[name]).to.exist.to.be.an.instanceOf(Function); }; }; diff --git a/test/utils/ensureProperty.js b/test/utils/ensureProperty.js index bfdde1474..e7b8b2309 100644 --- a/test/utils/ensureProperty.js +++ b/test/utils/ensureProperty.js @@ -1,7 +1,7 @@ -var expect = require('chai').expect; +const { expect } = require('chai'); -module.exports = function(obj, name, cls) { - return function() { +module.exports = function (obj, name, cls) { + return function () { expect(obj[name]).to.exist.to.be.an.instanceOf(cls); }; }; diff --git a/test/utils/extractParts.js b/test/utils/extractParts.js index 2a09fe95f..0ad320016 100644 --- a/test/utils/extractParts.js +++ b/test/utils/extractParts.js @@ -1,15 +1,13 @@ -module.exports = function(body, boundary) { - var partRegexp = new RegExp(boundary + '[-]{2}|' + boundary, 'g'); - var parts = {}; - var name; - var value; +module.exports = function (body, boundary) { + const partRegexp = new RegExp(`${boundary}[-]{2}|${boundary}`, 'g'); + const parts = {}; - body.split(partRegexp).forEach(function(part) { + body.split(partRegexp).forEach((part) => { // Ignore empty strings in the array. if (part.trim().length === 0) return; - name = part.match(/name="([^"]*)"/)[1]; - value = part.split('"' + name + '"')[1]; + const [, name] = part.match(/name="([^"]*)"/); + const [, value] = part.split(`"${name}"`); parts[name] = value.trim(); }); diff --git a/test/utils/index.js b/test/utils/index.js index 763766fc2..6882fef14 100644 --- a/test/utils/index.js +++ b/test/utils/index.js @@ -1,5 +1,5 @@ module.exports = { extractParts: require('./extractParts'), ensureProperty: require('./ensureProperty'), - ensureMethod: require('./ensureMethod') + ensureMethod: require('./ensureMethod'), }; diff --git a/webpack.config.js b/webpack.config.js index 889c6f6fe..7bf56604b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,55 +1,53 @@ -var Webpack = require('webpack'); -var pkg = require('./package.json'); +const Webpack = require('webpack'); +const pkg = require('./package.json'); -var StringReplacePlugin = require("string-replace-webpack-plugin"); +const StringReplacePlugin = require('string-replace-webpack-plugin'); module.exports = { entry: './src/index.js', output: { path: './build', - filename: pkg.name+'-'+pkg.version+'.min.js', + filename: `${pkg.name}-${pkg.version}.min.js`, library: 'Auth0', libraryTarget: 'umd', }, node: { Buffer: true, process: true, - url: true + url: true, }, module: { loaders: [ { test: /\.json$/, - loader: 'json' + loader: 'json', }, { test: /\.js$/, loader: StringReplacePlugin.replace({ replacements: [ { - // Remove User-agent for browser version - pattern: /'User-agent': 'node\.js/gmi, - replacement: function (match, p1, offset, string) { - return "// 'User-agent': 'node.js"; - }.bind(this) - } - ] - }) - } - ] + // Remove User-Agent for browser version + pattern: /'User-Agent': 'node\.js/gim, + replacement: () => "// 'User-Agent': 'node.js", + }, + ], + }), + }, + ], }, plugins: [ new StringReplacePlugin(), new Webpack.optimize.DedupePlugin(), new Webpack.optimize.UglifyJsPlugin({ compress: { - warnings: false - } - }) + warnings: false, + }, + }), ], resolve: { modulesDirectories: ['node_modules'], root: __dirname, alias: {}, - } + }, }; diff --git a/yarn.lock b/yarn.lock index 8531b7c3c..b1180ad20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,343 +2,885 @@ # yarn lockfile v1 +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.16.7": + version "7.16.7" + resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz" + integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== + dependencies: + "@babel/highlight" "^7.16.7" + +"@babel/generator@^7.18.0", "@babel/generator@^7.4.0": + version "7.18.0" + resolved "https://registry.npmjs.org/@babel/generator/-/generator-7.18.0.tgz" + integrity sha512-81YO9gGx6voPXlvYdZBliFXAZU8vZ9AZ6z+CjlmcnaeOcYSFbMTpdeDUO9xD9dh/68Vq03I8ZspfUTPfitcDHg== + dependencies: + "@babel/types" "^7.18.0" + "@jridgewell/gen-mapping" "^0.3.0" + jsesc "^2.5.1" + +"@babel/helper-environment-visitor@^7.16.7": + version "7.16.7" + resolved "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz" + integrity sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag== + dependencies: + "@babel/types" "^7.16.7" + +"@babel/helper-function-name@^7.17.9": + version "7.17.9" + resolved "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz" + integrity sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg== + dependencies: + "@babel/template" "^7.16.7" + "@babel/types" "^7.17.0" + +"@babel/helper-hoist-variables@^7.16.7": + version "7.16.7" + resolved "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz" + integrity sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg== + dependencies: + "@babel/types" "^7.16.7" + +"@babel/helper-split-export-declaration@^7.16.7": + version "7.16.7" + resolved "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz" + integrity sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw== + dependencies: + "@babel/types" "^7.16.7" + +"@babel/helper-validator-identifier@^7.16.7": + version "7.16.7" + resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz" + integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== + +"@babel/highlight@^7.16.7": + version "7.17.12" + resolved "https://registry.npmjs.org/@babel/highlight/-/highlight-7.17.12.tgz" + integrity sha512-7yykMVF3hfZY2jsHZEEgLc+3x4o1O+fYyULu11GynEUQNwB6lua+IIQn1FiJxNucd5UlyJryrwsOh8PL9Sn8Qg== + dependencies: + "@babel/helper-validator-identifier" "^7.16.7" + chalk "^2.0.0" + js-tokens "^4.0.0" + +"@babel/parser@^7.16.7", "@babel/parser@^7.18.0", "@babel/parser@^7.4.3", "@babel/parser@^7.9.4": + version "7.18.0" + resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.18.0.tgz" + integrity sha512-AqDccGC+m5O/iUStSJy3DGRIUFu7WbY/CppZYwrEUB4N0tZlnI8CSTsgL7v5fHVFmUbRv2sd+yy27o8Ydt4MGg== + +"@babel/template@^7.16.7", "@babel/template@^7.4.0": + version "7.16.7" + resolved "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz" + integrity sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w== + dependencies: + "@babel/code-frame" "^7.16.7" + "@babel/parser" "^7.16.7" + "@babel/types" "^7.16.7" + +"@babel/traverse@^7.4.3": + version "7.18.0" + resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.18.0.tgz" + integrity sha512-oNOO4vaoIQoGjDQ84LgtF/IAlxlyqL4TUuoQ7xLkQETFaHkY1F7yazhB4Kt3VcZGL0ZF/jhrEpnXqUb0M7V3sw== + dependencies: + "@babel/code-frame" "^7.16.7" + "@babel/generator" "^7.18.0" + "@babel/helper-environment-visitor" "^7.16.7" + "@babel/helper-function-name" "^7.17.9" + "@babel/helper-hoist-variables" "^7.16.7" + "@babel/helper-split-export-declaration" "^7.16.7" + "@babel/parser" "^7.18.0" + "@babel/types" "^7.18.0" + debug "^4.1.0" + globals "^11.1.0" + +"@babel/types@^7.16.7", "@babel/types@^7.17.0", "@babel/types@^7.18.0", "@babel/types@^7.4.0": + version "7.18.0" + resolved "https://registry.npmjs.org/@babel/types/-/types-7.18.0.tgz" + integrity sha512-vhAmLPAiC8j9K2GnsnLPCIH5wCrPpYIVBCWRBFDCB7Y/BXLqi/O+1RSTTM2bsmg6U/551+FCf9PNPxjABmxHTw== + dependencies: + "@babel/helper-validator-identifier" "^7.16.7" + to-fast-properties "^2.0.0" + +"@es-joy/jsdoccomment@~0.20.1": + version "0.20.1" + resolved "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.20.1.tgz" + integrity sha512-oeJK41dcdqkvdZy/HctKklJNkt/jh+av3PZARrZEl+fs/8HaHeeYoAvEwOV0u5I6bArTF17JEsTZMY359e/nfQ== + dependencies: + comment-parser "1.3.0" + esquery "^1.4.0" + jsdoc-type-pratt-parser "~2.2.3" + +"@eslint/eslintrc@^1.3.0": + version "1.3.0" + resolved "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz" + integrity sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw== + dependencies: + ajv "^6.12.4" + debug "^4.3.2" + espree "^9.3.2" + globals "^13.15.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" + +"@humanwhocodes/config-array@^0.9.2": + version "0.9.5" + resolved "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.5.tgz" + integrity sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw== + dependencies: + "@humanwhocodes/object-schema" "^1.2.1" + debug "^4.1.1" + minimatch "^3.0.4" + +"@humanwhocodes/object-schema@^1.2.1": + version "1.2.1" + resolved "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz" + integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== + +"@jridgewell/gen-mapping@^0.3.0": + version "0.3.1" + resolved "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz" + integrity sha512-GcHwniMlA2z+WFPWuY8lp3fsza0I8xPFMWL5+n8LYyP6PSvPrXf4+n8stDHZY2DM0zy9sVkRDy1jDI4XGzYVqg== + dependencies: + "@jridgewell/set-array" "^1.0.0" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.9" + +"@jridgewell/resolve-uri@^3.0.3": + version "3.0.7" + resolved "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz" + integrity sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA== + +"@jridgewell/set-array@^1.0.0": + version "1.1.1" + resolved "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.1.tgz" + integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.13" + resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz" + integrity sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w== + +"@jridgewell/trace-mapping@^0.3.9": + version "0.3.13" + resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz" + integrity sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + +"@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.3": + version "1.8.3" + resolved "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz" + integrity sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ== + dependencies: + type-detect "4.0.8" + +"@sinonjs/fake-timers@>=5", "@sinonjs/fake-timers@^9.1.2": + version "9.1.2" + resolved "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz" + integrity sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw== + dependencies: + "@sinonjs/commons" "^1.7.0" + +"@sinonjs/samsam@^6.1.1": + version "6.1.1" + resolved "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-6.1.1.tgz" + integrity sha512-cZ7rKJTLiE7u7Wi/v9Hc2fs3Ucc3jrWeMgPHbbTCeVAB2S0wOBbYlkJVeNSL04i7fdhT8wIbDq1zhC/PXTD2SA== + dependencies: + "@sinonjs/commons" "^1.6.0" + lodash.get "^4.4.2" + type-detect "^4.0.8" + +"@sinonjs/text-encoding@^0.7.1": + version "0.7.1" + resolved "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz" + integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ== + +"@tootallnate/once@1": + version "1.1.2" + resolved "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz" + integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== + "@types/body-parser@*": - version "1.17.0" - resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.17.0.tgz#9f5c9d9bd04bb54be32d5eb9fc0d8c974e6cf58c" + version "1.19.2" + resolved "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz" + integrity sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g== dependencies: "@types/connect" "*" "@types/node" "*" "@types/connect@*": - version "3.4.32" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.32.tgz#aa0e9616b9435ccad02bc52b5b454ffc2c70ba28" + version "3.4.35" + resolved "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz" + integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== dependencies: "@types/node" "*" -"@types/events@*": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86" +"@types/express-serve-static-core@^4.17.31": + version "4.17.31" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz#a1139efeab4e7323834bb0226e62ac019f474b2f" + integrity sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" -"@types/express-jwt@0.0.34": - version "0.0.34" - resolved "https://registry.yarnpkg.com/@types/express-jwt/-/express-jwt-0.0.34.tgz#fdbee4c6af5c0a246ef2a933f5519973c7717f02" +"@types/express@^4.17.14": + version "4.17.15" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.15.tgz#9290e983ec8b054b65a5abccb610411953d417ff" + integrity sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ== dependencies: - "@types/express" "*" - "@types/express-unless" "*" + "@types/body-parser" "*" + "@types/express-serve-static-core" "^4.17.31" + "@types/qs" "*" + "@types/serve-static" "*" -"@types/express-serve-static-core@*": - version "4.16.0" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.16.0.tgz#fdfe777594ddc1fe8eb8eccce52e261b496e43e7" +"@types/jsonwebtoken@^8.5.9": + version "8.5.9" + resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-8.5.9.tgz#2c064ecb0b3128d837d2764aa0b117b0ff6e4586" + integrity sha512-272FMnFGzAVMGtu9tkr29hRL6bZj4Zs1KZNeHLnKqAvp06tAIcarTMwOh8/8bz4FmKRcMxZhZNeUAQsNLoiPhg== dependencies: - "@types/events" "*" "@types/node" "*" - "@types/range-parser" "*" -"@types/express-unless@*": - version "0.0.32" - resolved "https://registry.yarnpkg.com/@types/express-unless/-/express-unless-0.0.32.tgz#783f3cc1fa5e67cc2ed30000f3e1f22501f75d50" - dependencies: - "@types/express" "*" +"@types/linkify-it@*": + version "3.0.2" + resolved "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz" + integrity sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA== -"@types/express@*": - version "4.16.0" - resolved "https://registry.yarnpkg.com/@types/express/-/express-4.16.0.tgz#6d8bc42ccaa6f35cf29a2b7c3333cb47b5a32a19" +"@types/markdown-it@^12.2.3": + version "12.2.3" + resolved "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz" + integrity sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ== dependencies: - "@types/body-parser" "*" - "@types/express-serve-static-core" "*" - "@types/serve-static" "*" + "@types/linkify-it" "*" + "@types/mdurl" "*" -"@types/mime@*": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.0.tgz#5a7306e367c539b9f6543499de8dd519fac37a8b" +"@types/mdurl@*": + version "1.0.2" + resolved "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz" + integrity sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA== + +"@types/mime@^1": + version "1.3.2" + resolved "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz" + integrity sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw== "@types/node@*": - version "10.7.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.7.1.tgz#b704d7c259aa40ee052eec678758a68d07132a2e" + version "17.0.35" + resolved "https://registry.npmjs.org/@types/node/-/node-17.0.35.tgz" + integrity sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg== + +"@types/normalize-package-data@^2.4.0": + version "2.4.1" + resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz" + integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw== + +"@types/qs@*": + version "6.9.7" + resolved "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz" + integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== "@types/range-parser@*": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.2.tgz#fa8e1ad1d474688a757140c91de6dace6f4abc8d" + version "1.2.4" + resolved "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz" + integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== "@types/serve-static@*": - version "1.13.2" - resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.2.tgz#f5ac4d7a6420a99a6a45af4719f4dcd8cd907a48" + version "1.13.10" + resolved "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.10.tgz" + integrity sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ== dependencies: - "@types/express-serve-static-core" "*" - "@types/mime" "*" + "@types/mime" "^1" + "@types/node" "*" -abbrev@1, abbrev@1.0.x: - version "1.0.9" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" +"@ungap/promise-all-settled@1.1.2": + version "1.1.2" + resolved "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz" + integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== -acorn@^3.0.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" +"@webassemblyjs/ast@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz" + integrity sha512-C6wW5L+b7ogSDVqymbkkvuW9kruN//YisMED04xzeBBqjHa2FYnmvOlS6Xj68xWQRgWvI9cIglsjFowH/RJyEA== + dependencies: + "@webassemblyjs/helper-module-context" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/wast-parser" "1.9.0" -agent-base@2, agent-base@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-2.1.1.tgz#d6de10d5af6132d5bd692427d46fc538539094c7" +"@webassemblyjs/floating-point-hex-parser@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.9.0.tgz" + integrity sha512-TG5qcFsS8QB4g4MhrxK5TqfdNe7Ey/7YL/xN+36rRjl/BlGE/NcBvJcqsRgCP6Z92mRE+7N50pRIi8SmKUbcQA== + +"@webassemblyjs/helper-api-error@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.9.0.tgz" + integrity sha512-NcMLjoFMXpsASZFxJ5h2HZRcEhDkvnNFOAKneP5RbKRzaWJN36NC4jqQHKwStIhGXu5mUWlUUk7ygdtrO8lbmw== + +"@webassemblyjs/helper-buffer@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.9.0.tgz" + integrity sha512-qZol43oqhq6yBPx7YM3m9Bv7WMV9Eevj6kMi6InKOuZxhw+q9hOkvq5e/PpKSiLfyetpaBnogSbNCfBwyB00CA== + +"@webassemblyjs/helper-code-frame@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.9.0.tgz" + integrity sha512-ERCYdJBkD9Vu4vtjUYe8LZruWuNIToYq/ME22igL+2vj2dQ2OOujIZr3MEFvfEaqKoVqpsFKAGsRdBSBjrIvZA== dependencies: - extend "~3.0.0" - semver "~5.0.1" + "@webassemblyjs/wast-printer" "1.9.0" -agent-base@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.1.1.tgz#92d8a4fc2524a3b09b3666a33b6c97960f23d6a4" +"@webassemblyjs/helper-fsm@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.9.0.tgz" + integrity sha512-OPRowhGbshCb5PxJ8LocpdX9Kl0uB4XsAjl6jH/dWKlk/mzsANvhwbiULsaiqT5GZGT9qinTICdj6PLuM5gslw== + +"@webassemblyjs/helper-module-context@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.9.0.tgz" + integrity sha512-MJCW8iGC08tMk2enck1aPW+BE5Cw8/7ph/VGZxwyvGbJwjktKkDK7vy7gAmMDx88D7mhDTCNKAW5tED+gZ0W8g== + dependencies: + "@webassemblyjs/ast" "1.9.0" + +"@webassemblyjs/helper-wasm-bytecode@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.9.0.tgz" + integrity sha512-R7FStIzyNcd7xKxCZH5lE0Bqy+hGTwS3LJjuv1ZVxd9O7eHCedSdrId/hMOd20I+v8wDXEn+bjfKDLzTepoaUw== + +"@webassemblyjs/helper-wasm-section@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.9.0.tgz" + integrity sha512-XnMB8l3ek4tvrKUUku+IVaXNHz2YsJyOOmz+MMkZvh8h1uSJpSen6vYnw3IoQ7WwEuAhL8Efjms1ZWjqh2agvw== dependencies: - es6-promisify "^5.0.0" + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-buffer" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/wasm-gen" "1.9.0" -ajv@^4.9.1: - version "4.11.8" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" +"@webassemblyjs/ieee754@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.9.0.tgz" + integrity sha512-dcX8JuYU/gvymzIHc9DgxTzUUTLexWwt8uCTWP3otys596io0L5aW02Gb1RjYpx2+0Jus1h4ZFqjla7umFniTg== dependencies: - co "^4.6.0" - json-stable-stringify "^1.0.1" + "@xtuc/ieee754" "^1.2.0" -ajv@^5.1.0: - version "5.2.3" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.3.tgz#c06f598778c44c6b161abafe3466b81ad1814ed2" +"@webassemblyjs/leb128@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.9.0.tgz" + integrity sha512-ENVzM5VwV1ojs9jam6vPys97B/S65YQtv/aanqnU7D8aSoHFX8GyhGg0CMfyKNIHBuAVjy3tlzd5QMMINa7wpw== dependencies: - co "^4.6.0" - fast-deep-equal "^1.0.0" - json-schema-traverse "^0.3.0" - json-stable-stringify "^1.0.1" + "@xtuc/long" "4.2.2" -ajv@^5.3.0: - version "5.5.2" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" +"@webassemblyjs/utf8@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.9.0.tgz" + integrity sha512-GZbQlWtopBTP0u7cHrEx+73yZKrQoBMpwkGEIqlacljhXCkVM1kMQge/Mf+csMJAjEdSwhOyLAS0AoR3AG5P8w== + +"@webassemblyjs/wasm-edit@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.9.0.tgz" + integrity sha512-FgHzBm80uwz5M8WKnMTn6j/sVbqilPdQXTWraSjBwFXSYGirpkSWE2R9Qvz9tNiTKQvoKILpCuTjBKzOIm0nxw== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-buffer" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/helper-wasm-section" "1.9.0" + "@webassemblyjs/wasm-gen" "1.9.0" + "@webassemblyjs/wasm-opt" "1.9.0" + "@webassemblyjs/wasm-parser" "1.9.0" + "@webassemblyjs/wast-printer" "1.9.0" + +"@webassemblyjs/wasm-gen@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.9.0.tgz" + integrity sha512-cPE3o44YzOOHvlsb4+E9qSqjc9Qf9Na1OO/BHFy4OI91XDE14MjFN4lTMezzaIWdPqHnsTodGGNP+iRSYfGkjA== dependencies: - co "^4.6.0" - fast-deep-equal "^1.0.0" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.3.0" + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/ieee754" "1.9.0" + "@webassemblyjs/leb128" "1.9.0" + "@webassemblyjs/utf8" "1.9.0" -align-text@^0.1.1, align-text@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" +"@webassemblyjs/wasm-opt@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.9.0.tgz" + integrity sha512-Qkjgm6Anhm+OMbIL0iokO7meajkzQD71ioelnfPEj6r4eOFuqm4YC3VBPqXjFyyNwowzbMD+hizmprP/Fwkl2A== dependencies: - kind-of "^3.0.2" - longest "^1.0.1" - repeat-string "^1.5.2" + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-buffer" "1.9.0" + "@webassemblyjs/wasm-gen" "1.9.0" + "@webassemblyjs/wasm-parser" "1.9.0" + +"@webassemblyjs/wasm-parser@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.9.0.tgz" + integrity sha512-9+wkMowR2AmdSWQzsPEjFU7njh8HTO5MqO8vjwEHuM+AMHioNqSBONRdr0NQQ3dVQrzp0s8lTcYqzUdb7YgELA== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-api-error" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/ieee754" "1.9.0" + "@webassemblyjs/leb128" "1.9.0" + "@webassemblyjs/utf8" "1.9.0" + +"@webassemblyjs/wast-parser@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.9.0.tgz" + integrity sha512-qsqSAP3QQ3LyZjNC/0jBJ/ToSxfYJ8kYyuiGvtn/8MK89VrNEfwj7BPQzJVHi0jGTRK2dGdJ5PRqhtjzoww+bw== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/floating-point-hex-parser" "1.9.0" + "@webassemblyjs/helper-api-error" "1.9.0" + "@webassemblyjs/helper-code-frame" "1.9.0" + "@webassemblyjs/helper-fsm" "1.9.0" + "@xtuc/long" "4.2.2" + +"@webassemblyjs/wast-printer@1.9.0": + version "1.9.0" + resolved "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.9.0.tgz" + integrity sha512-2J0nE95rHXHyQ24cWjMKJ1tqB/ds8z/cyeOZxJhcb+rW+SQASVjuznUSmdz5GpVJTzU8JkhYut0D3siFDD6wsA== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/wast-parser" "1.9.0" + "@xtuc/long" "4.2.2" + +"@xtuc/ieee754@^1.2.0": + version "1.2.0" + resolved "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz" + integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== + +"@xtuc/long@4.2.2": + version "4.2.2" + resolved "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz" + integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== + +acorn-jsx@^5.3.2: + version "5.3.2" + resolved "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz" + integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== + +acorn-walk@^8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + +acorn@^6.4.1: + version "6.4.2" + resolved "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz" + integrity sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ== + +acorn@^8.7.0: + version "8.8.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8" + integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w== + +acorn@^8.7.1: + version "8.7.1" + resolved "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz" + integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== + +agent-base@6, agent-base@^6.0.0, agent-base@^6.0.2: + version "6.0.2" + resolved "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz" + integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== + dependencies: + debug "4" + +ajv-errors@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz" + integrity sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ== + +ajv-keywords@^3.1.0, ajv-keywords@^3.4.1: + version "3.5.2" + resolved "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz" + integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== + +ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4: + version "6.12.6" + resolved "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" amdefine@>=0.0.4: version "1.0.1" - resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + resolved "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" + integrity sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg== -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" +ansi-regex@^3.0.0: + version "3.0.1" + resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz" + integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw== -ansi-styles@^3.2.1: +ansi-regex@^4.1.0: + version "4.1.1" + resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== dependencies: color-convert "^1.9.0" -anymatch@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== dependencies: - arrify "^1.0.0" - micromatch "^2.1.5" + color-convert "^2.0.1" -aproba@^1.0.3: - version "1.1.2" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" +anymatch@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz" + integrity sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw== + dependencies: + micromatch "^3.1.4" + normalize-path "^2.1.1" -are-we-there-yet@~1.1.2: - version "1.1.4" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" +anymatch@~3.1.1: + version "3.1.2" + resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz" + integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== dependencies: - delegates "^1.0.0" - readable-stream "^2.0.6" + normalize-path "^3.0.0" + picomatch "^2.0.4" + +append-transform@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/append-transform/-/append-transform-1.0.0.tgz" + integrity sha512-P009oYkeHyU742iSZJzZZywj4QRJdnTWffaKuJQLablCZ1uz6/cW4yaRgcDaoQ+uwOxxnt0gRUcwfsNP2ri0gw== + dependencies: + default-require-extensions "^2.0.0" + +aproba@^1.1.1: + version "1.2.0" + resolved "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz" + integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== + +archy@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz" + integrity sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw== argparse@^1.0.7: - version "1.0.9" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" + version "1.0.10" + resolved "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== dependencies: sprintf-js "~1.0.2" -argv@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/argv/-/argv-0.0.2.tgz#ecbd16f8949b157183711b1bda334f37840185ab" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== -arr-diff@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz" + integrity sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA== + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz" + integrity sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q== + +array-differ@^2.0.3: + version "2.1.0" + resolved "https://registry.npmjs.org/array-differ/-/array-differ-2.1.0.tgz" + integrity sha512-KbUpJgx909ZscOc/7CLATBFam7P1Z1QRQInvgT0UztM9Q72aGKCunKASAl7WNW0tnPmPyEMeMhdsfWhfmW037w== + +array-union@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz" + integrity sha512-Dxr6QJj/RdU/hCaBjOfxW+q6lyuVE6JFWIrAUpuOOhoJJoQ99cUn3igRaHVB5P9WrgFVN0FfArM3x0cueOU8ng== dependencies: - arr-flatten "^1.0.1" + array-uniq "^1.0.1" -arr-flatten@^1.0.1: +array-uniq@^1.0.1: version "1.0.3" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" + resolved "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz" + integrity sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q== -array-unique@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz" + integrity sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ== -arrify@^1.0.0: +arrify@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - -asn1@~0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + resolved "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz" + integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== -assert-plus@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" +asn1.js@^5.2.0: + version "5.4.1" + resolved "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz" + integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== + dependencies: + bn.js "^4.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + safer-buffer "^2.1.0" assert@^1.1.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91" + version "1.5.0" + resolved "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz" + integrity sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA== dependencies: + object-assign "^4.1.1" util "0.10.3" -assertion-error@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.0.tgz#c7f85438fdd466bc7ca16ab90c81513797a5d23b" - -ast-types@0.x.x: - version "0.9.14" - resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.14.tgz#d34ba5dffb9d15a44351fd2a9d82e4ab2838b5ba" +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz" + integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== -async-each@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz" + integrity sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw== -async@1.x, async@^1.3.0, async@^1.4.0: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" +ast-types@^0.13.2: + version "0.13.4" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782" + integrity sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w== + dependencies: + tslib "^2.0.1" -async@^0.9.0: - version "0.9.2" - resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" +async-each@^1.0.1: + version "1.0.3" + resolved "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz" + integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ== -async@~0.2.10, async@~0.2.6: +async@~0.2.10: version "0.2.10" - resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" + resolved "https://registry.npmjs.org/async/-/async-0.2.10.tgz" + integrity sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ== asynckit@^0.4.0: version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - -aws-sign2@~0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" - -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" - -aws4@^1.2.1, aws4@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -aws4@^1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" +atob@^2.1.2: + version "2.1.2" + resolved "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== -babylon@7.0.0-beta.19: - version "7.0.0-beta.19" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.19.tgz#e928c7e807e970e0536b078ab3e0c48f9e052503" +axios@^0.27.2: + version "0.27.2" + resolved "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz" + integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== + dependencies: + follow-redirects "^1.14.9" + form-data "^4.0.0" balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + version "1.0.2" + resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== base64-js@^1.0.2: - version "1.2.0" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1" - -bcrypt-pbkdf@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" - dependencies: - tweetnacl "^0.14.3" + version "1.5.1" + resolved "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.npmjs.org/base/-/base-0.11.2.tgz" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" big.js@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" + version "3.2.0" + resolved "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz" + integrity sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q== -binary-extensions@^1.0.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" +big.js@^5.2.2: + version "5.2.2" + resolved "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz" + integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== -block-stream@*: - version "0.0.9" - resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" - dependencies: - inherits "~2.0.0" - -bluebird@^2.10.2: - version "2.11.0" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" +binary-extensions@^1.0.0: + version "1.13.1" + resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz" + integrity sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw== -bluebird@~3.5.0: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== -boom@2.x.x: - version "2.10.1" - resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" +bindings@^1.5.0: + version "1.5.0" + resolved "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== dependencies: - hoek "2.x.x" + file-uri-to-path "1.0.0" -boom@4.x.x: - version "4.3.1" - resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" - dependencies: - hoek "4.x.x" +bluebird@^3.5.5, bluebird@^3.7.2: + version "3.7.2" + resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz" + integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== + +bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: + version "4.12.0" + resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -boom@5.x.x: +bn.js@^5.0.0, bn.js@^5.1.1: version "5.2.0" - resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" - dependencies: - hoek "4.x.x" + resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz" + integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== brace-expansion@^1.1.7: - version "1.1.8" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" + version "1.1.11" + resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== dependencies: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^1.8.2: - version "1.8.5" - resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" - dependencies: - expand-range "^1.8.1" - preserve "^0.2.0" +braces@^2.3.1, braces@^2.3.2: + version "2.3.2" + resolved "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" -browserify-aes@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-0.4.0.tgz#067149b668df31c4b58533e02d01e806d8608e2c" +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +brorand@^1.0.1, brorand@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz" + integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +browserify-aes@^1.0.0, browserify-aes@^1.0.4: + version "1.2.0" + resolved "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz" + integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== dependencies: + buffer-xor "^1.0.3" + cipher-base "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.3" inherits "^2.0.1" + safe-buffer "^5.0.1" -browserify-zlib@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.1.4.tgz#bb35f8a519f600e0fa6b8485241c979d0141fb2d" +browserify-cipher@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz" + integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== + dependencies: + browserify-aes "^1.0.4" + browserify-des "^1.0.0" + evp_bytestokey "^1.0.0" + +browserify-des@^1.0.0: + version "1.0.2" + resolved "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz" + integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== dependencies: - pako "~0.2.0" + cipher-base "^1.0.1" + des.js "^1.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: + version "4.1.0" + resolved "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz" + integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== + dependencies: + bn.js "^5.0.0" + randombytes "^2.0.1" + +browserify-sign@^4.0.0: + version "4.2.1" + resolved "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz" + integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== + dependencies: + bn.js "^5.1.1" + browserify-rsa "^4.0.1" + create-hash "^1.2.0" + create-hmac "^1.1.7" + elliptic "^6.5.3" + inherits "^2.0.4" + parse-asn1 "^5.1.5" + readable-stream "^3.6.0" + safe-buffer "^5.2.0" + +browserify-zlib@^0.2.0: + version "0.2.0" + resolved "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz" + integrity sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA== + dependencies: + pako "~1.0.5" buffer-equal-constant-time@1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" + resolved "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz" + integrity sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA== + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +buffer-xor@^1.0.3: + version "1.0.3" + resolved "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz" + integrity sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ== -buffer@^4.9.0: - version "4.9.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-4.9.1.tgz#6d1bb601b07a4efced97094132093027c95bc298" +buffer@^4.3.0: + version "4.9.2" + resolved "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz" + integrity sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg== dependencies: base64-js "^1.0.2" ieee754 "^1.1.4" @@ -346,72 +888,151 @@ buffer@^4.9.0: builtin-status-codes@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" + resolved "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz" + integrity sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ== -bytes@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" +bytes@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" + integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== + +cacache@^12.0.2: + version "12.0.4" + resolved "https://registry.npmjs.org/cacache/-/cacache-12.0.4.tgz" + integrity sha512-a0tMB40oefvuInr4Cwb3GerbL9xTj1D5yg0T5xrjGCGyfvbxseIXX7BAO/u/hIXdafzOI5JC3wDwHyf24buOAQ== + dependencies: + bluebird "^3.5.5" + chownr "^1.1.1" + figgy-pudding "^3.5.1" + glob "^7.1.4" + graceful-fs "^4.1.15" + infer-owner "^1.0.3" + lru-cache "^5.1.1" + mississippi "^3.0.0" + mkdirp "^0.5.1" + move-concurrently "^1.0.1" + promise-inflight "^1.0.1" + rimraf "^2.6.3" + ssri "^6.0.1" + unique-filename "^1.1.1" + y18n "^4.0.0" + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +caching-transform@^3.0.2: + version "3.0.2" + resolved "https://registry.npmjs.org/caching-transform/-/caching-transform-3.0.2.tgz" + integrity sha512-Mtgcv3lh3U0zRii/6qVgQODdPA4G3zhG+jtbCWj39RXuUFTMzH0vcdMtaJS1jPowd+It2Pqr6y3NJMQqOqCE2w== + dependencies: + hasha "^3.0.0" + make-dir "^2.0.0" + package-hash "^3.0.0" + write-file-atomic "^2.4.2" -camel-case@^1.1.1: - version "1.2.2" - resolved "https://registry.yarnpkg.com/camel-case/-/camel-case-1.2.2.tgz#1aca7c4d195359a2ce9955793433c6e5542511f2" +call-bind@^1.0.0: + version "1.0.2" + resolved "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz" + integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== dependencies: - sentence-case "^1.1.1" - upper-case "^1.1.1" + function-bind "^1.1.1" + get-intrinsic "^1.0.2" -camelcase@^1.0.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" +caller-callsite@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz" + integrity sha512-JuG3qI4QOftFsZyOn1qq87fq5grLIyk1JYd5lJmdA+fG7aQ9pA/i3JIJGcO3q0MrRcHlOt1U+ZeHW8Dq9axALQ== + dependencies: + callsites "^2.0.0" -caseless@~0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" +caller-path@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz" + integrity sha512-MCL3sf6nCSXOwCTzvPKhN18TU7AHTvdtam8DAogxcrJ8Rjfbbg7Lgng64H9Iy+vUV6VGFClN/TyxBkAebLRR4A== + dependencies: + caller-callsite "^2.0.0" -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" +callsites@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz" + integrity sha512-ksWePWBloaWPxJYQ8TL0JHvtci6G5QTKwQ95RcWAa/lzoAKuAOflGdAK92hpHXjkwb8zLxoLNUoNYZgVsaJzvQ== -catharsis@~0.8.9: - version "0.8.9" - resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b" - dependencies: - underscore-contrib "~0.3.0" +callsites@^3.0.0: + version "3.1.0" + resolved "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz" + integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -center-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" +camel-case@^1.1.1: + version "1.2.2" + resolved "https://registry.npmjs.org/camel-case/-/camel-case-1.2.2.tgz" + integrity sha512-rUug78lL8mqStaLehmH2F0LxMJ2TM9fnPFxb+gFkgyUjUM/1o2wKTQtalypHnkb2cFwH/DENBw7YEAOYLgSMxQ== dependencies: - align-text "^0.1.3" - lazy-cache "^1.0.3" + sentence-case "^1.1.1" + upper-case "^1.1.1" -"chai@>=1.9.2 <4.0.0", chai@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/chai/-/chai-2.3.0.tgz#8a2f6a34748da801090fd73287b2aa739a4e909a" +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +catharsis@^0.9.0: + version "0.9.0" + resolved "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz" + integrity sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A== dependencies: - assertion-error "1.0.0" - deep-eql "0.1.3" + lodash "^4.17.15" -chalk@^1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" +chai@^4.2.0: + version "4.3.6" + resolved "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz" + integrity sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q== dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + loupe "^2.3.1" + pathval "^1.1.1" + type-detect "^4.0.5" -chalk@^2.3.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65" +chalk@^2.0.0, chalk@^2.3.0, chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== dependencies: ansi-styles "^3.2.1" escape-string-regexp "^1.0.5" supports-color "^5.3.0" +chalk@^4.0.0: + version "4.1.2" + resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + change-case@^2.3.0: version "2.3.1" - resolved "https://registry.yarnpkg.com/change-case/-/change-case-2.3.1.tgz#2c4fde3f063bb41d00cd68e0d5a09db61cbe894f" + resolved "https://registry.npmjs.org/change-case/-/change-case-2.3.1.tgz" + integrity sha512-3HE5jrTqqn9jeKzD0+yWi7FU4OMicLbwB57ph4bpwEn5jGi3hZug5WjZjnBD2RY7YyTKAAck86ACfShXUWJKLg== dependencies: camel-case "^1.1.1" constant-case "^1.1.0" @@ -430,166 +1051,349 @@ change-case@^2.3.0: upper-case "^1.1.1" upper-case-first "^1.1.0" -charenc@~0.0.1: +charenc@0.0.2: version "0.0.2" - resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" + resolved "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz" + integrity sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA== -chokidar@^1.0.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" - dependencies: - anymatch "^1.3.0" - async-each "^1.0.0" - glob-parent "^2.0.0" - inherits "^2.0.1" +check-error@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz" + integrity sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA== + +chokidar@3.5.1, chokidar@^3.4.1: + version "3.5.1" + resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz" + integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.5.0" + optionalDependencies: + fsevents "~2.3.1" + +chokidar@^2.1.8: + version "2.1.8" + resolved "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz" + integrity sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg== + dependencies: + anymatch "^2.0.0" + async-each "^1.0.1" + braces "^2.3.2" + glob-parent "^3.1.0" + inherits "^2.0.3" is-binary-path "^1.0.0" - is-glob "^2.0.0" + is-glob "^4.0.0" + normalize-path "^3.0.0" path-is-absolute "^1.0.0" - readdirp "^2.0.0" + readdirp "^2.2.1" + upath "^1.1.1" optionalDependencies: - fsevents "^1.0.0" + fsevents "^1.2.7" -ci-info@^1.0.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.3.tgz#710193264bb05c77b8c90d02f5aaf22216a667b2" +chownr@^1.1.1: + version "1.1.4" + resolved "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz" + integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== -cliui@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" +chrome-trace-event@^1.0.2: + version "1.0.3" + resolved "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz" + integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== + +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + +cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: + version "1.0.4" + resolved "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz" + integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== dependencies: - center-align "^0.1.1" - right-align "^0.1.1" - wordwrap "0.0.2" + inherits "^2.0.1" + safe-buffer "^5.0.1" -clone@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.2.tgz#260b7a99ebb1edfe247538175f783243cb19d149" +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" -co@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" -codecov@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/codecov/-/codecov-2.2.0.tgz#2d06817ceb8891eca6368836d4fb6bf6cc04ffd1" +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz" + integrity "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==" dependencies: - argv "0.0.2" - request "2.79.0" - urlgrey "0.4.4" + map-visit "^1.0.0" + object-visit "^1.0.0" color-convert@^1.9.0: - version "1.9.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.1.tgz#c1261107aeb2f294ebffec9ed9ecad529a6097ed" + version "1.9.3" + resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== dependencies: - color-name "^1.1.1" + color-name "~1.1.4" -color-name@^1.1.1: +color-name@1.1.3: version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" + integrity "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" -combined-stream@1.0.6, combined-stream@~1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" - dependencies: - delayed-stream "~1.0.0" +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -combined-stream@^1.0.5, combined-stream@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== dependencies: delayed-stream "~1.0.0" -commander@0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-0.6.1.tgz#fa68a14f6a945d54dbbe50d8cdb3320e9e3b1a06" +commander@^2.20.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" +comment-parser@1.3.0: + version "1.3.0" + resolved "https://registry.npmjs.org/comment-parser/-/comment-parser-1.3.0.tgz" + integrity sha512-hRpmWIKgzd81vn0ydoWoyPoALEOnF4wt8yKD35Ib1D6XC2siLiYaiqfGkYrunuKdsXGwpBpHU3+9r+RVw2NZfA== -commander@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" - dependencies: - graceful-readlink ">= 1.0.0" +commondir@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz" + integrity "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==" -component-emitter@^1.2.0: - version "1.2.1" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" +component-emitter@^1.2.1, component-emitter@^1.3.0: + version "1.3.0" + resolved "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== concat-map@0.0.1: version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + integrity "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" -console-browserify@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" +concat-stream@^1.5.0: + version "1.6.2" + resolved "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== dependencies: - date-now "^0.1.4" + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" -console-control-strings@^1.0.0, console-control-strings@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" +console-browserify@^1.1.0: + version "1.2.0" + resolved "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz" + integrity sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA== constant-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/constant-case/-/constant-case-1.1.2.tgz#8ec2ca5ba343e00aa38dbf4e200fd5ac907efd63" + resolved "https://registry.npmjs.org/constant-case/-/constant-case-1.1.2.tgz" + integrity "sha1-jsLKW6ND4Aqjjb9OIA/VrJB+/WM= sha512-FQ/HuOuSnX6nIF8OnofRWj+KnOpGAHXQpOKHmsL1sAnuLwu6r5mHGK+mJc0SkHkbmNfcU/SauqXLTEOL1JQfJA==" dependencies: snake-case "^1.1.0" upper-case "^1.1.1" constants-browserify@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" + resolved "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz" + integrity "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U= sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==" -cookiejar@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.1.tgz#41ad57b1b555951ec171412a81942b1e8200d34a" +convert-source-map@^1.6.0: + version "1.8.0" + resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz" + integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== + dependencies: + safe-buffer "~5.1.1" + +cookiejar@^2.1.2: + version "2.1.3" + resolved "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz" + integrity sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ== + +copy-concurrently@^1.0.0: + version "1.0.5" + resolved "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz" + integrity sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A== + dependencies: + aproba "^1.1.1" + fs-write-stream-atomic "^1.0.8" + iferr "^0.1.5" + mkdirp "^0.5.1" + rimraf "^2.5.4" + run-queue "^1.0.0" + +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz" + integrity "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==" core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + version "1.0.3" + resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz" + integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== + +cosmiconfig@^5.2.1: + version "5.2.1" + resolved "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz" + integrity sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA== + dependencies: + import-fresh "^2.0.0" + is-directory "^0.3.1" + js-yaml "^3.13.1" + parse-json "^4.0.0" + +cp-file@^6.2.0: + version "6.2.0" + resolved "https://registry.npmjs.org/cp-file/-/cp-file-6.2.0.tgz" + integrity sha512-fmvV4caBnofhPe8kOcitBwSn2f39QLjnAnGq3gO9dfd75mUytzKNZB1hde6QHunW2Rt+OwuBOMc3i1tNElbszA== + dependencies: + graceful-fs "^4.1.2" + make-dir "^2.0.0" + nested-error-stacks "^2.0.0" + pify "^4.0.1" + safe-buffer "^5.0.1" + +create-ecdh@^4.0.0: + version "4.0.4" + resolved "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz" + integrity sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A== + dependencies: + bn.js "^4.1.0" + elliptic "^6.5.3" + +create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: + version "1.2.0" + resolved "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz" + integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== + dependencies: + cipher-base "^1.0.1" + inherits "^2.0.1" + md5.js "^1.3.4" + ripemd160 "^2.0.1" + sha.js "^2.4.0" + +create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: + version "1.1.7" + resolved "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz" + integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== + dependencies: + cipher-base "^1.0.3" + create-hash "^1.1.0" + inherits "^2.0.1" + ripemd160 "^2.0.0" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +cross-env@^5.2.0: + version "5.2.1" + resolved "https://registry.npmjs.org/cross-env/-/cross-env-5.2.1.tgz" + integrity sha512-1yHhtcfAd1r4nwQgknowuUNfIT9E8dOMMspC36g45dN+iD1blloi7xp8X/xAIDnjHWyt1uQ8PHk2fkNaym7soQ== + dependencies: + cross-spawn "^6.0.5" + +cross-spawn@^4: + version "4.0.2" + resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz" + integrity "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE= sha512-yAXz/pA1tD8Gtg2S98Ekf/sewp3Lcp3YoFKJ4Hkp5h5yLWnKVTDU0kwjKJ8NDCYcfTLfyGkzTikst+jWypT1iA==" + dependencies: + lru-cache "^4.0.1" + which "^1.2.9" cross-spawn@^5.0.1: version "5.1.0" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" + resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz" + integrity "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==" dependencies: lru-cache "^4.0.1" shebang-command "^1.2.0" which "^1.2.9" -crypt@~0.0.1: - version "0.0.2" - resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" - -cryptiles@2.x.x: - version "2.0.5" - resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" +cross-spawn@^6.0.0, cross-spawn@^6.0.5: + version "6.0.5" + resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== dependencies: - boom "2.x.x" + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" -cryptiles@3.x.x: - version "3.1.2" - resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" +cross-spawn@^7.0.2: + version "7.0.3" + resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== dependencies: - boom "5.x.x" + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" -crypto-browserify@3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.3.0.tgz#b9fc75bb4a0ed61dcf1cd5dae96eb30c9c3e506c" - dependencies: - browserify-aes "0.4.0" - pbkdf2-compat "2.0.1" - ripemd160 "0.2.0" - sha.js "2.2.6" +crypt@0.0.2: + version "0.0.2" + resolved "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz" + integrity "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==" + +crypto-browserify@^3.11.0: + version "3.12.0" + resolved "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz" + integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== + dependencies: + browserify-cipher "^1.0.0" + browserify-sign "^4.0.0" + create-ecdh "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.0" + diffie-hellman "^5.0.0" + inherits "^2.0.1" + pbkdf2 "^3.0.3" + public-encrypt "^4.0.0" + randombytes "^2.0.0" + randomfill "^1.0.3" css-loader@^0.9.1: version "0.9.1" - resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-0.9.1.tgz#2e1aa00ce7e30ef2c6a7a4b300a080a7c979e0dc" + resolved "https://registry.npmjs.org/css-loader/-/css-loader-0.9.1.tgz" + integrity "sha1-LhqgDOfjDvLGp6SzAKCAp8l54Nw= sha512-gRUrW6PKtgZrWaJ/w51C7N4MblnSe7LicfyX36YiN4gAK7QBNZ9VT3wxZDcyzW6zAkEpk7f/92v9258dCIKdEQ==" dependencies: csso "1.3.x" loader-utils "~0.2.2" @@ -597,212 +1401,481 @@ css-loader@^0.9.1: csso@1.3.x: version "1.3.12" - resolved "https://registry.yarnpkg.com/csso/-/csso-1.3.12.tgz#fc628694a2d38938aaac4996753218fd311cdb9e" - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - dependencies: - assert-plus "^1.0.0" + resolved "https://registry.npmjs.org/csso/-/csso-1.3.12.tgz" + integrity "sha1-/GKGlKLTiTiqrEmWdTIY/TEc254= sha512-K5CSPbOVumvT1ceFb+maul2vow0WrTGxF3PXJpyjOuxilSGwgPqbub2M8oHTLz0hJ7lzSKBFSKTx299fpttlmQ==" -data-uri-to-buffer@1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz#77163ea9c20d8641b4707e8f18abdf9a78f34835" +cyclist@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz" + integrity "sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk= sha512-NJGVKPS81XejHcLhaLJS7plab0fK3slPh11mESeeDq2W4ZI5kUKK/LRRdVDvjJseojbPB7ZwjnyOybg3Igea/A==" -date-now@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" +data-uri-to-buffer@3: + version "3.0.1" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz#594b8973938c5bc2c33046535785341abc4f3636" + integrity sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og== -debug@2, debug@^2.6.8: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: - ms "2.0.0" + ms "2.1.2" -debug@2.2.0, debug@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" +debug@4.3.1: + version "4.3.1" + resolved "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz" + integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== dependencies: - ms "0.7.1" + ms "2.1.2" -debug@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" +debug@^2.2.0, debug@^2.3.3: + version "2.6.9" + resolved "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== dependencies: ms "2.0.0" -debug@~0.7.4: - version "0.7.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" - -decamelize@^1.0.0: +decamelize@^1.2.0: version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + resolved "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz" + integrity "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==" -deep-eql@0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2" +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz" + integrity "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==" + +deep-eql@^3.0.1: + version "3.0.1" + resolved "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz" + integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw== dependencies: - type-detect "0.1.1" + type-detect "^4.0.0" -deep-equal@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" +deep-is@^0.1.3, deep-is@~0.1.3: + version "0.1.4" + resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz" + integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -deep-extend@~0.4.0: - version "0.4.2" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" +deepmerge@^3.2.0: + version "3.3.0" + resolved "https://registry.npmjs.org/deepmerge/-/deepmerge-3.3.0.tgz" + integrity sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA== -deep-is@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" +default-require-extensions@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-2.0.0.tgz" + integrity "sha1-9fj7sYp9bVCyH2QfZJ67Uiz+JPc= sha512-B0n2zDIXpzLzKeoEozorDSa1cHc1t0NjmxP0zuAxbizNU2MBqYJJKYXrrFdKuQliojXynrxgd7l4ahfg/+aA5g==" + dependencies: + strip-bom "^3.0.0" -deepmerge@^1.5.1: - version "1.5.2" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.5.2.tgz#10499d868844cdad4fee0842df8c7f6f0c95a753" +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz" + integrity "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==" + dependencies: + is-descriptor "^0.1.0" -define-properties@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz" + integrity "sha1-dp66rz9KY6rTr56NMEybvnm/sOY= sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==" dependencies: - foreach "^2.0.5" - object-keys "^1.0.8" + is-descriptor "^1.0.0" -degenerator@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-1.0.4.tgz#fcf490a37ece266464d9cc431ab98c5819ced095" +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== dependencies: - ast-types "0.x.x" - escodegen "1.x.x" - esprima "3.x.x" + is-descriptor "^1.0.2" + isobject "^3.0.1" + +degenerator@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-3.0.2.tgz#6a61fcc42a702d6e50ff6023fe17bff435f68235" + integrity sha512-c0mef3SNQo56t6urUU6tdQAs+ThoD0o9B9MJ8HEt7NQcGEILCRFqQb7ZbP9JAv+QF1Ky5plydhMR/IrqWDm+TQ== + dependencies: + ast-types "^0.13.2" + escodegen "^1.8.1" + esprima "^4.0.0" + vm2 "^3.9.8" delayed-stream@~1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + resolved "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" + integrity "sha1-3zrhmayt+31ECqrgsp4icrJOxhk= sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" -delegates@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" +depd@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== -depd@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" +des.js@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz" + integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== + dependencies: + inherits "^2.0.1" + minimalistic-assert "^1.0.0" -diff@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" +diff@5.0.0, diff@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +diffie-hellman@^5.0.0: + version "5.0.3" + resolved "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz" + integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== + dependencies: + bn.js "^4.1.0" + miller-rabin "^4.0.0" + randombytes "^2.0.0" + +doctrine@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz" + integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== + dependencies: + esutils "^2.0.2" domain-browser@^1.1.1: - version "1.1.7" - resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" + version "1.2.0" + resolved "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz" + integrity sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA== dot-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-1.1.2.tgz#1e73826900de28d6de5480bc1de31d0842b06bec" + resolved "https://registry.npmjs.org/dot-case/-/dot-case-1.1.2.tgz" + integrity "sha1-HnOCaQDeKNbeVIC8HeMdCEKwa+w= sha512-NzEIt12UjECXi6JZ/R/nBey6EE1qCN0yUTEFaPIaKW0AcOEwlKqujtcJVbtSfLNnj3CDoXLQyli79vAaqohyvw==" dependencies: sentence-case "^1.1.2" -ecc-jsbn@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" +duplexify@^3.4.2, duplexify@^3.6.0: + version "3.7.1" + resolved "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz" + integrity sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g== dependencies: - jsbn "~0.1.0" + end-of-stream "^1.0.0" + inherits "^2.0.1" + readable-stream "^2.0.0" + stream-shift "^1.0.0" -ecdsa-sig-formatter@1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz#1c595000f04a8897dfb85000892a0f4c33af86c3" +ecdsa-sig-formatter@1.0.11: + version "1.0.11" + resolved "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz" + integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== dependencies: safe-buffer "^5.0.1" +elliptic@^6.5.3: + version "6.5.4" + resolved "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + emojis-list@^2.0.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" + resolved "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz" + integrity "sha1-TapNnbAPmBmIDHn6RXrlsJof04k= sha512-knHEZMgs8BB+MInokmNTg/OyPlAddghe1YBgNwJBc5zsJi/uyIcXoSDsL/W9ymOsBoBGdPIHXYJ9+qKFwRwDng==" -enhanced-resolve@~0.9.0: - version "0.9.1" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz#4d6e689b3725f86090927ccc86cd9f1635b89e2e" +emojis-list@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz" + integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== + +end-of-stream@^1.0.0, end-of-stream@^1.1.0: + version "1.4.4" + resolved "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz" + integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== dependencies: - graceful-fs "^4.1.2" - memory-fs "^0.2.0" - tapable "^0.1.8" + once "^1.4.0" -errno@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d" +enhanced-resolve@^4.5.0: + version "4.5.0" + resolved "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.5.0.tgz" + integrity sha512-Nv9m36S/vxpsI+Hc4/ZGRs0n9mXqSWGGq49zxb/cJfPAQMbUtttJAlNPS4AQzaBdw/pKskw5bMbekT/Y7W/Wlg== dependencies: - prr "~0.0.0" + graceful-fs "^4.1.2" + memory-fs "^0.5.0" + tapable "^1.0.0" -es6-promise@^4.0.3: - version "4.1.1" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.1.1.tgz#8811e90915d9a0dba36274f0b242dbda78f9c92a" +entities@~2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz" + integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w== -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" +errno@^0.1.3, errno@~0.1.7: + version "0.1.8" + resolved "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz" + integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== dependencies: - es6-promise "^4.0.3" + prr "~1.0.1" -es6-promisify@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-6.0.0.tgz#b526a75eaa5ca600e960bf3d5ad98c40d75c7203" +error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" -escape-string-regexp@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz#4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1" +es6-error@^4.0.1: + version "4.1.1" + resolved "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz" + integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.5: +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +escape-string-regexp@^1.0.5: version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" + integrity "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==" + +escape-string-regexp@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz" + integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== -escodegen@1.8.x: - version "1.8.1" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018" +escodegen@^1.8.1: + version "1.14.3" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503" + integrity sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw== dependencies: - esprima "^2.7.1" - estraverse "^1.9.1" + esprima "^4.0.1" + estraverse "^4.2.0" esutils "^2.0.2" optionator "^0.8.1" optionalDependencies: - source-map "~0.2.0" + source-map "~0.6.1" -escodegen@1.x.x: - version "1.9.0" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.9.0.tgz#9811a2f265dc1cd3894420ee3717064b632b8852" +eslint-config-prettier@^8.5.0: + version "8.5.0" + resolved "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz" + integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q== + +eslint-plugin-es@^3.0.0: + version "3.0.1" + resolved "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz" + integrity sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ== + dependencies: + eslint-utils "^2.0.0" + regexpp "^3.0.0" + +eslint-plugin-jsdoc@^37.0.3: + version "37.9.7" + resolved "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.9.7.tgz" + integrity sha512-8alON8yYcStY94o0HycU2zkLKQdcS+qhhOUNQpfONHHwvI99afbmfpYuPqf6PbLz5pLZldG3Te5I0RbAiTN42g== + dependencies: + "@es-joy/jsdoccomment" "~0.20.1" + comment-parser "1.3.0" + debug "^4.3.3" + escape-string-regexp "^4.0.0" + esquery "^1.4.0" + regextras "^0.8.0" + semver "^7.3.5" + spdx-expression-parse "^3.0.1" + +eslint-plugin-node@^11.1.0: + version "11.1.0" + resolved "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz" + integrity sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g== + dependencies: + eslint-plugin-es "^3.0.0" + eslint-utils "^2.0.0" + ignore "^5.1.1" + minimatch "^3.0.4" + resolve "^1.10.1" + semver "^6.1.0" + +eslint-plugin-prettier@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz" + integrity sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ== dependencies: - esprima "^3.1.3" - estraverse "^4.2.0" + prettier-linter-helpers "^1.0.0" + +eslint-plugin-promise@^6.0.0: + version "6.0.0" + resolved "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.0.0.tgz" + integrity sha512-7GPezalm5Bfi/E22PnQxDWH2iW9GTvAlUNTztemeHb6c1BniSyoeTrM87JkC0wYdi6aQrZX9p2qEiAno8aTcbw== + +eslint-scope@^4.0.3: + version "4.0.3" + resolved "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz" + integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-scope@^7.1.1: + version "7.1.1" + resolved "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz" + integrity sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw== + dependencies: + esrecurse "^4.3.0" + estraverse "^5.2.0" + +eslint-utils@^2.0.0: + version "2.1.0" + resolved "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz" + integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== + dependencies: + eslint-visitor-keys "^1.1.0" + +eslint-utils@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz" + integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== + dependencies: + eslint-visitor-keys "^2.0.0" + +eslint-visitor-keys@^1.1.0: + version "1.3.0" + resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== + +eslint-visitor-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz" + integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== + +eslint-visitor-keys@^3.3.0: + version "3.3.0" + resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz" + integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== + +eslint@^8.16.0: + version "8.16.0" + resolved "https://registry.npmjs.org/eslint/-/eslint-8.16.0.tgz" + integrity sha512-MBndsoXY/PeVTDJeWsYj7kLZ5hQpJOfMYLsF6LicLHQWbRDG19lK5jOix4DPl8yY4SUFcE3txy86OzFLWT+yoA== + dependencies: + "@eslint/eslintrc" "^1.3.0" + "@humanwhocodes/config-array" "^0.9.2" + ajv "^6.10.0" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" + doctrine "^3.0.0" + escape-string-regexp "^4.0.0" + eslint-scope "^7.1.1" + eslint-utils "^3.0.0" + eslint-visitor-keys "^3.3.0" + espree "^9.3.2" + esquery "^1.4.0" esutils "^2.0.2" - optionator "^0.8.1" - optionalDependencies: - source-map "~0.5.6" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + functional-red-black-tree "^1.0.1" + glob-parent "^6.0.1" + globals "^13.15.0" + ignore "^5.2.0" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + js-yaml "^4.1.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" + natural-compare "^1.4.0" + optionator "^0.9.1" + regexpp "^3.2.0" + strip-ansi "^6.0.1" + strip-json-comments "^3.1.0" + text-table "^0.2.0" + v8-compile-cache "^2.0.3" + +espree@^9.3.2: + version "9.3.2" + resolved "https://registry.npmjs.org/espree/-/espree-9.3.2.tgz" + integrity sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA== + dependencies: + acorn "^8.7.1" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.3.0" + +esprima@^4.0.0, esprima@^4.0.1: + version "4.0.1" + resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1: - version "2.7.3" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" +esquery@^1.4.0: + version "1.4.0" + resolved "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz" + integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== + dependencies: + estraverse "^5.1.0" -esprima@3.x.x, esprima@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" +esrecurse@^4.1.0, esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" -estraverse@^1.9.1: - version "1.9.3" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" +estraverse@^4.1.1, estraverse@^4.2.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== -estraverse@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" +estraverse@^5.1.0, estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== esutils@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + version "2.0.3" + resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -events@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" +events@^3.0.0: + version "3.3.0" + resolved "https://registry.npmjs.org/events/-/events-3.3.0.tgz" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + +evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: + version "1.0.3" + resolved "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz" + integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== + dependencies: + md5.js "^1.3.4" + safe-buffer "^5.1.1" execa@^0.8.0: version "0.8.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.8.0.tgz#d8d76bbc1b55217ed190fd6dd49d3c774ecfc8da" + resolved "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz" + integrity "sha1-2NdrvBtVIX7RkP1t1J08d07PyNo= sha512-zDWS+Rb1E8BlqqhALSt9kUhss8Qq4nN3iof3gsOdyINksElaPyNBtKUMTR62qhvgVWR0CqCX7sdnKe4MnUbFEA==" dependencies: cross-spawn "^5.0.1" get-stream "^3.0.0" @@ -812,253 +1885,395 @@ execa@^0.8.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -expand-brackets@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" +execa@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz" + integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== dependencies: - is-posix-bracket "^0.1.0" + cross-spawn "^6.0.0" + get-stream "^4.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" -expand-range@^1.8.1: - version "1.8.2" - resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz" + integrity "sha1-t3c14xXOMPa27/D4OwQVGiJEliI= sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==" + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz" + integrity "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==" dependencies: - fill-range "^2.1.0" + is-extendable "^0.1.0" -extend@3, extend@^3.0.0, extend@~3.0.0, extend@~3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" - -extend@~3.0.2: +extend-shallow@^3.0.0, extend-shallow@^3.0.2: version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - -extglob@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + resolved "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz" + integrity "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==" dependencies: - is-extglob "^1.0.0" + assign-symbols "^1.0.0" + is-extendable "^1.0.1" -extsprintf@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-deep-equal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== fast-json-stable-stringify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + version "2.1.0" + resolved "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== -fast-levenshtein@~2.0.4: +fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz" + integrity "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" + +fast-safe-stringify@^2.0.7: + version "2.1.1" + resolved "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz" + integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA== + +figgy-pudding@^3.5.1: + version "3.5.2" + resolved "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz" + integrity sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw== + +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== + dependencies: + flat-cache "^3.0.4" file-loader@^0.8.1: version "0.8.5" - resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-0.8.5.tgz#9275d031fe780f27d47f5f4af02bd43713cc151b" + resolved "https://registry.npmjs.org/file-loader/-/file-loader-0.8.5.tgz" + integrity "sha1-knXQMf54DyfUf19K8CvUNxPMFRs= sha512-yDylQzd/QOaMm249awSL+JjsLRDfFghwmm+YCALH0uLXqAazD/alHnhbIE+UyVtbI+bIVYVdgDApSJ9blouFDg==" dependencies: loader-utils "~0.2.5" -file-uri-to-path@1: +file-uri-to-path@1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + resolved "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== -filename-regex@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" +file-uri-to-path@2: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz#7b415aeba227d575851e0a5b0c640d7656403fba" + integrity sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg== fill-keys@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/fill-keys/-/fill-keys-1.0.2.tgz#9a8fa36f4e8ad634e3bf6b4f3c8882551452eb20" + resolved "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz" + integrity "sha1-mo+jb06K1jTjv2tPPIiCVRRS6yA= sha512-tcgI872xXjwFF4xgQmLxi76GnwJG3g/3isB1l4/G5Z4zrbddGpBjqZCO9oEAcB5wX0Hj/5iQB3toxfO7in1hHA==" dependencies: is-object "~1.0.1" merge-descriptors "~1.0.0" -fill-range@^2.1.0: - version "2.2.3" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz" + integrity "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==" dependencies: - is-number "^2.1.0" - isobject "^2.0.0" - randomatic "^1.1.3" - repeat-element "^1.1.2" - repeat-string "^1.5.2" + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-cache-dir@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz" + integrity sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ== + dependencies: + commondir "^1.0.1" + make-dir "^2.0.0" + pkg-dir "^3.0.0" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" find-up@^2.1.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + resolved "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz" + integrity "sha1-RdG35QbHF93UgndaK3eSCjwMV6c= sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==" dependencies: locate-path "^2.0.0" -for-in@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" +find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" -for-own@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" +find-up@^4.0.0: + version "4.1.0" + resolved "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== dependencies: - for-in "^1.0.1" + locate-path "^5.0.0" + path-exists "^4.0.0" -foreach@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" +flat-cache@^3.0.4: + version "3.0.4" + resolved "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz" + integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== + dependencies: + flatted "^3.1.0" + rimraf "^3.0.2" -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== -form-data@^2.3.1, form-data@~2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.1.tgz#6fb94fbd71885306d73d15cc497fe4cc4ecd44bf" +flatted@^3.1.0: + version "3.2.5" + resolved "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz" + integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== + +flush-write-stream@^1.0.0: + version "1.1.1" + resolved "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz" + integrity sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w== dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.5" - mime-types "^2.1.12" + inherits "^2.0.3" + readable-stream "^2.3.6" -form-data@~2.1.1: - version "2.1.4" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" +follow-redirects@^1.14.9: + version "1.15.1" + resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz" + integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA== + +for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz" + integrity "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==" + +foreground-child@^1.5.6: + version "1.5.6" + resolved "https://registry.npmjs.org/foreground-child/-/foreground-child-1.5.6.tgz" + integrity "sha1-T9ca0t/elnibmApcCilZN8svXOk= sha512-3TOY+4TKV0Ml83PXJQY+JFQaHNV38lzQDIzzXYg1kWdBLenGgoZhAs0CKgzI31vi2pWEpQMq/Yi4bpKwCPkw7g==" dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.5" - mime-types "^2.1.12" + cross-spawn "^4" + signal-exit "^3.0.0" -form-data@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" +form-data@^3.0.0, form-data@^3.0.1: + version "3.0.1" + resolved "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz" + integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== dependencies: asynckit "^0.4.0" - combined-stream "1.0.6" + combined-stream "^1.0.8" mime-types "^2.1.12" -formatio@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== dependencies: - samsam "~1.1" + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" -formidable@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.1.1.tgz#96b8886f7c3c3508b932d6bd70c4d3a88f35f1a9" +formidable@^1.2.2: + version "1.2.6" + resolved "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz" + integrity sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ== -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz" + integrity "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==" + dependencies: + map-cache "^0.2.2" -fsevents@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" +from2@^2.1.0: + version "2.3.0" + resolved "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz" + integrity "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8= sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==" dependencies: - nan "^2.3.0" - node-pre-gyp "^0.6.36" + inherits "^2.0.1" + readable-stream "^2.0.0" -fstream-ignore@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" +fs-extra@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" + integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== dependencies: - fstream "^1.0.0" - inherits "2" - minimatch "^3.0.0" + graceful-fs "^4.2.0" + jsonfile "^4.0.0" + universalify "^0.1.0" -fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: - version "1.0.11" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" +fs-write-stream-atomic@^1.0.8: + version "1.0.10" + resolved "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz" + integrity "sha1-tH31NJPvkR33VzHnCp3tAYnbQMk= sha512-gehEzmPn2nAwr39eay+x3X34Ra+M2QlVUTLhkXPjWdeO8RF9kszk116avgBJM3ZyNHgHXBNx+VmPaFC36k0PzA==" dependencies: graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" + iferr "^0.1.5" + imurmurhash "^0.1.4" + readable-stream "1 || 2" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" + integrity "sha1-FQStJSMVjKpA20onh8sBQRmU6k8= sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + +fsevents@^1.2.7: + version "1.2.13" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz" + integrity sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw== + dependencies: + bindings "^1.5.0" + nan "^2.12.1" + +fsevents@~2.3.1: + version "2.3.2" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -ftp@~0.3.10: +ftp@^0.3.10: version "0.3.10" resolved "https://registry.yarnpkg.com/ftp/-/ftp-0.3.10.tgz#9197d861ad8142f3e63d5a83bfe4c59f7330885d" + integrity sha512-faFVML1aBx2UoDStmLwv2Wptt4vw5x03xxX172nhA5Y5HBshW5JweqQ2W4xL4dezQTG8inJsuYcpPHHU3X5OTQ== dependencies: readable-stream "1.1.x" xregexp "2.0.0" -function-bind@^1.1.0: +function-bind@^1.1.1: version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== -gauge@~2.7.3: - version "2.7.4" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" - dependencies: - aproba "^1.0.3" - console-control-strings "^1.0.0" - has-unicode "^2.0.0" - object-assign "^4.1.0" - signal-exit "^3.0.0" - string-width "^1.0.1" - strip-ansi "^3.0.1" - wide-align "^1.1.0" +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz" + integrity "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==" + +get-caller-file@^2.0.1, get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -generate-function@^2.0.0: +get-func-name@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + resolved "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz" + integrity "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==" -generate-object-property@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" +get-intrinsic@^1.0.2: + version "1.1.1" + resolved "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz" + integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== dependencies: - is-property "^1.0.0" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + +get-stdin@^7.0.0: + version "7.0.0" + resolved "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz" + integrity sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ== get-stream@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + resolved "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz" + integrity "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==" -get-uri@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-2.0.1.tgz#dbdcacacd8c608a38316869368117697a1631c59" +get-stream@^4.0.0: + version "4.1.0" + resolved "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== dependencies: - data-uri-to-buffer "1" - debug "2" - extend "3" - file-uri-to-path "1" - ftp "~0.3.10" - readable-stream "2" + pump "^3.0.0" -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" +get-uri@3: + version "3.0.2" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-3.0.2.tgz#f0ef1356faabc70e1f9404fa3b66b2ba9bfc725c" + integrity sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg== dependencies: - assert-plus "^1.0.0" + "@tootallnate/once" "1" + data-uri-to-buffer "3" + debug "4" + file-uri-to-path "2" + fs-extra "^8.1.0" + ftp "^0.3.10" -glob-base@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" - dependencies: - glob-parent "^2.0.0" - is-glob "^2.0.0" +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz" + integrity "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==" -glob-parent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" +glob-parent@^3.1.0: + version "3.1.0" + resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz" + integrity "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==" dependencies: - is-glob "^2.0.0" + is-glob "^3.1.0" + path-dirname "^1.0.0" -glob@3.2.11: - version "3.2.11" - resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d" +glob-parent@^6.0.1: + version "6.0.2" + resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== dependencies: - inherits "2" - minimatch "0.3" + is-glob "^4.0.3" -glob@^5.0.15: - version "5.0.15" - resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" +glob-parent@~5.1.0: + version "5.1.2" + resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: - inflight "^1.0.4" - inherits "2" - minimatch "2 || 3" - once "^1.3.0" - path-is-absolute "^1.0.0" + is-glob "^4.0.1" -glob@^7.0.5: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" +glob@7.1.6, glob@^7.1.3, glob@^7.1.4: + version "7.1.6" + resolved "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -1067,2043 +2282,3195 @@ glob@^7.0.5: once "^1.3.0" path-is-absolute "^1.0.0" -graceful-fs@^4.1.2, graceful-fs@^4.1.9: - version "4.1.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" +globals@^11.1.0: + version "11.12.0" + resolved "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz" + integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -"graceful-readlink@>= 1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" +globals@^13.15.0: + version "13.15.0" + resolved "https://registry.npmjs.org/globals/-/globals-13.15.0.tgz" + integrity sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog== + dependencies: + type-fest "^0.20.2" -growl@1.9.2: - version "1.9.2" - resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0: + version "4.2.10" + resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== -handlebars@^4.0.1: - version "4.0.10" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" - dependencies: - async "^1.4.0" - optimist "^0.6.1" - source-map "^0.4.4" - optionalDependencies: - uglify-js "^2.6" +growl@1.10.5: + version "1.10.5" + resolved "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz" + integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== -har-schema@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz" + integrity "sha1-tdRU3CGZriJWmfNGfloH87lVuv0= sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==" -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -har-validator@~2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" +has-symbols@^1.0.1: + version "1.0.3" + resolved "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz" + integrity "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==" dependencies: - chalk "^1.1.1" - commander "^2.9.0" - is-my-json-valid "^2.12.4" - pinkie-promise "^2.0.0" + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" -har-validator@~4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz" + integrity "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==" dependencies: - ajv "^4.9.1" - har-schema "^1.0.5" + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" -har-validator@~5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz" + integrity "sha1-bWHeldkd/Km5oCCJrThL/49it3E= sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==" + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz" + integrity "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==" + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +has@^1.0.3: + version "1.0.3" + resolved "https://registry.npmjs.org/has/-/has-1.0.3.tgz" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== dependencies: - ajv "^5.1.0" - har-schema "^2.0.0" + function-bind "^1.1.1" -har-validator@~5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.0.tgz#44657f5688a22cfd4b72486e81b3a3fb11742c29" +hash-base@^3.0.0: + version "3.1.0" + resolved "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz" + integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== dependencies: - ajv "^5.3.0" - har-schema "^2.0.0" + inherits "^2.0.4" + readable-stream "^3.6.0" + safe-buffer "^5.2.0" -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" +hash.js@^1.0.0, hash.js@^1.0.3: + version "1.1.7" + resolved "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz" + integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== dependencies: - ansi-regex "^2.0.0" + inherits "^2.0.3" + minimalistic-assert "^1.0.1" -has-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" - -has-flag@^3.0.0: +hasha@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + resolved "https://registry.npmjs.org/hasha/-/hasha-3.0.0.tgz" + integrity "sha1-UqMvq4Vp1BymmmH/GiFPjrfIvTk= sha512-w0Kz8lJFBoyaurBiNrIvxPqr/gJ6fOfSkpAPOepN3oECqGJag37xPbOv57izi/KP8auHgNYxn5fXtAb+1LsJ6w==" + dependencies: + is-stream "^1.0.1" -has-unicode@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" +he@1.2.0: + version "1.2.0" + resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -hawk@~3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" +hmac-drbg@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz" + integrity "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==" dependencies: - boom "2.x.x" - cryptiles "2.x.x" - hoek "2.x.x" - sntp "1.x.x" + hash.js "^1.0.3" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.1" -hawk@~6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" - dependencies: - boom "4.x.x" - cryptiles "3.x.x" - hoek "4.x.x" - sntp "2.x.x" +hosted-git-info@^2.1.4: + version "2.8.9" + resolved "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz" + integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== -hoek@2.x.x: - version "2.16.3" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" +html-escaper@^2.0.0: + version "2.0.2" + resolved "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz" + integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== -hoek@4.x.x: - version "4.2.0" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" +http-errors@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== + dependencies: + depd "2.0.0" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" -http-errors@1.6.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" +http-proxy-agent@^4.0.0, http-proxy-agent@^4.0.1: + version "4.0.1" + resolved "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz" + integrity sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg== dependencies: - depd "1.1.1" - inherits "2.0.3" - setprototypeof "1.0.3" - statuses ">= 1.3.1 < 2" + "@tootallnate/once" "1" + agent-base "6" + debug "4" -http-proxy-agent@1, http-proxy-agent@^1.0.0: +https-browserify@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-1.0.0.tgz#cc1ce38e453bf984a0f7702d2dd59c73d081284a" - dependencies: - agent-base "2" - debug "2" - extend "3" + resolved "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz" + integrity "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==" -http-signature@~1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" +https-proxy-agent@5, https-proxy-agent@^5.0.0: + version "5.0.1" + resolved "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz" + integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== dependencies: - assert-plus "^0.2.0" - jsprim "^1.2.2" - sshpk "^1.7.0" + agent-base "6" + debug "4" -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" +husky@^3.0.1: + version "3.1.0" + resolved "https://registry.npmjs.org/husky/-/husky-3.1.0.tgz" + integrity sha512-FJkPoHHB+6s4a+jwPqBudBDvYZsoQW5/HBuMSehC8qDiCe50kpcxeqFoDSlow+9I6wg47YxBoT3WxaURlrDIIQ== + dependencies: + chalk "^2.4.2" + ci-info "^2.0.0" + cosmiconfig "^5.2.1" + execa "^1.0.0" + get-stdin "^7.0.0" + opencollective-postinstall "^2.0.2" + pkg-dir "^4.2.0" + please-upgrade-node "^3.2.0" + read-pkg "^5.2.0" + run-node "^1.0.0" + slash "^3.0.0" + +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" -https-browserify@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" +ieee754@^1.1.4: + version "1.2.1" + resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== -https-proxy-agent@1, https-proxy-agent@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz#35f7da6c48ce4ddbfa264891ac593ee5ff8671e6" - dependencies: - agent-base "2" - debug "2" - extend "3" +iferr@^0.1.5: + version "0.1.5" + resolved "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz" + integrity "sha1-xg7taebY/bazEEofy8ocGS3FtQE= sha512-DUNFN5j7Tln0D+TxzloUjKB+CtVu6myn0JEFak6dG18mNt9YkQ6lzGCdafwofISZ1lLF3xRHJ98VKy9ynkcFaA==" -husky@^0.14.3: - version "0.14.3" - resolved "https://registry.yarnpkg.com/husky/-/husky-0.14.3.tgz#c69ed74e2d2779769a17ba8399b54ce0b63c12c3" - dependencies: - is-ci "^1.0.10" - normalize-path "^1.0.0" - strip-indent "^2.0.0" +ignore@^3.3.7: + version "3.3.10" + resolved "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz" + integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug== -iconv-lite@0.4.19: - version "0.4.19" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" +ignore@^5.1.1, ignore@^5.2.0: + version "5.2.0" + resolved "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz" + integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== -ieee754@^1.1.4: - version "1.1.8" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" +import-fresh@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz" + integrity "sha1-2BNVwVYS04bGH53dOSLUMEgipUY= sha512-eZ5H8rcgYazHbKC3PG4ClHNykCSxtAhxSSEM+2mb+7evD2CKF5V7c0dNum7AdpDh0ZdICwZY9sRSn8f+KH96sg==" + dependencies: + caller-path "^2.0.0" + resolve-from "^3.0.0" -ignore@^3.3.7: - version "3.3.7" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" +import-fresh@^3.0.0, import-fresh@^3.2.1: + version "3.3.0" + resolved "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz" + integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" -indexof@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" + integrity "sha1-khi5srkoojixPcT7a21XbyMUU+o= sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==" + +infer-owner@^1.0.3: + version "1.0.4" + resolved "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz" + integrity sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A== inflight@^1.0.4: version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" + integrity "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==" dependencies: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3: + version "2.0.4" + resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== inherits@2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + integrity "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE= sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA==" -ini@~1.3.0: - version "1.3.4" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz" + integrity "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" -interpret@^0.6.4: - version "0.6.6" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-0.6.6.tgz#fecd7a18e7ce5ca6abfb953e1f86213a49f1625b" +ip@^1.1.5: + version "1.1.8" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48" + integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg== -ip@^1.1.4, ip@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" +ip@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" + integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== + +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz" + integrity "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==" + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz" + integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== + dependencies: + kind-of "^6.0.0" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz" + integrity "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" is-binary-path@^1.0.0: version "1.0.1" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz" + integrity "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg= sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==" dependencies: binary-extensions "^1.0.0" -is-buffer@^1.1.5, is-buffer@~1.1.1: - version "1.1.5" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" - -is-ci@^1.0.10: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.1.0.tgz#247e4162e7860cebbdaf30b774d6b0ac7dcfe7a5" +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== dependencies: - ci-info "^1.0.0" + binary-extensions "^2.0.0" -is-dotfile@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" +is-buffer@^1.1.5, is-buffer@~1.1.6: + version "1.1.6" + resolved "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== -is-equal-shallow@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" +is-core-module@^2.8.1: + version "2.9.0" + resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz" + integrity sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A== dependencies: - is-primitive "^2.0.0" + has "^1.0.3" -is-extendable@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz" + integrity "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==" + dependencies: + kind-of "^3.0.2" -is-extglob@^1.0.0: +is-data-descriptor@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + resolved "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz" + integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== + dependencies: + kind-of "^6.0.0" -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz" + integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== dependencies: - number-is-nan "^1.0.0" + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" -is-glob@^2.0.0, is-glob@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz" + integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== dependencies: - is-extglob "^1.0.0" + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" -is-lower-case@^1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/is-lower-case/-/is-lower-case-1.1.3.tgz#7e147be4768dc466db3bfb21cc60b31e6ad69393" +is-directory@^0.3.1: + version "0.3.1" + resolved "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz" + integrity "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE= sha512-yVChGzahRFvbkscn2MlwGismPO12i9+znNruC5gVEntG3qu0xQMzsGg/JFbrsqDOHtHFPci+V5aP5T9I+yeKqw==" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz" + integrity "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==" + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== dependencies: - lower-case "^1.1.0" + is-plain-object "^2.0.4" + +is-extglob@^2.1.0, is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" + integrity "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz" + integrity "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==" + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== -is-my-json-valid@^2.12.4: - version "2.16.0" - resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz#f079dd9bfdae65ee2038aae8acbc86ab109e3693" +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz" + integrity "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==" dependencies: - generate-function "^2.0.0" - generate-object-property "^1.1.0" - jsonpointer "^4.0.0" - xtend "^4.0.0" + is-extglob "^2.1.0" -is-number@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== dependencies: - kind-of "^3.0.2" + is-extglob "^2.1.1" + +is-lower-case@^1.1.0: + version "1.1.3" + resolved "https://registry.npmjs.org/is-lower-case/-/is-lower-case-1.1.3.tgz" + integrity "sha1-fhR75HaNxGbbO/shzGCzHmrWk5M= sha512-+5A1e/WJpLLXZEDlgz4G//WYSHyQBD32qa4Jd3Lw06qQlv3fJHnp3YIHjTQSGzHMgzmVKz2ZP3rBxTHkPw/lxA==" + dependencies: + lower-case "^1.1.0" is-number@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + resolved "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz" + integrity "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==" dependencies: kind-of "^3.0.2" -is-object@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.1.tgz#8952688c5ec2ffd6b03ecc85e769e02903083470" - -is-posix-bracket@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" - -is-primitive@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-property@^1.0.0: +is-object@~1.0.1: version "1.0.2" - resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + resolved "https://registry.npmjs.org/is-object/-/is-object-1.0.2.tgz" + integrity sha512-2rRIahhZr2UWb45fIOuvZGpFtz0TyOZLf32KxBbSoUCeZR495zCKlWUKKUByk3geS2eAs7ZAABt0Y/Rx0GiQGA== -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== -is-string@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.4.tgz#cc3a9b69857d621e963725a24caeec873b826e64" +is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" +is-stream@^1.0.1, is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz" + integrity "sha1-EtSj3U5o4Lec6428hBc66A2RykQ= sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==" is-upper-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/is-upper-case/-/is-upper-case-1.1.2.tgz#8d0b1fa7e7933a1e58483600ec7d9661cbaf756f" + resolved "https://registry.npmjs.org/is-upper-case/-/is-upper-case-1.1.2.tgz" + integrity "sha1-jQsfp+eTOh5YSDYA7H2WYcuvdW8= sha512-GQYSJMgfeAmVwh9ixyk888l7OIhNAGKtY6QA+IrWlu9MDTCaXmeozOZ2S9Knj7bQwBO/H6J2kb+pbyTUiMNbsw==" dependencies: upper-case "^1.1.0" +is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== + +is-wsl@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz" + integrity "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0= sha512-gfygJYZ2gLTDlmbWMI0CE2MwnFzSN/2SZfkMlItC4K/JBlsWVDB0bO6XhqcY13YXE7iMcAJnzTCJjPiTeJJ0Mw==" + isarray@0.0.1: version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + resolved "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + integrity "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" + integrity "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" isexe@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" + integrity "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" isobject@^2.0.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + resolved "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz" + integrity "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==" dependencies: isarray "1.0.0" -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - -istanbul@^0.4.0: - version "0.4.5" - resolved "https://registry.yarnpkg.com/istanbul/-/istanbul-0.4.5.tgz#65c7d73d4c4da84d4f3ac310b918fb0b8033733b" - dependencies: - abbrev "1.0.x" - async "1.x" - escodegen "1.8.x" - esprima "2.7.x" - glob "^5.0.15" - handlebars "^4.0.1" - js-yaml "3.x" - mkdirp "0.5.x" - nopt "3.x" - once "1.x" - resolve "1.1.x" - supports-color "^3.1.0" - which "^1.1.1" - wordwrap "^1.0.0" - -jade@0.26.3: - version "0.26.3" - resolved "https://registry.yarnpkg.com/jade/-/jade-0.26.3.tgz#8f10d7977d8d79f2f6ff862a81b0513ccb25686c" - dependencies: - commander "0.6.1" - mkdirp "0.3.0" - -js-yaml@3.x: - version "3.6.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30" +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz" + integrity "sha1-TkMekrEalzFjaqH5yNHMvP2reN8= sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==" + +istanbul-lib-coverage@^2.0.5: + version "2.0.5" + resolved "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz" + integrity sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA== + +istanbul-lib-hook@^2.0.7: + version "2.0.7" + resolved "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-2.0.7.tgz" + integrity sha512-vrRztU9VRRFDyC+aklfLoeXyNdTfga2EI3udDGn4cZ6fpSXpHLV9X6CHvfoMCPtggg8zvDDmC4b9xfu0z6/llA== + dependencies: + append-transform "^1.0.0" + +istanbul-lib-instrument@^3.3.0: + version "3.3.0" + resolved "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz" + integrity sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA== + dependencies: + "@babel/generator" "^7.4.0" + "@babel/parser" "^7.4.3" + "@babel/template" "^7.4.0" + "@babel/traverse" "^7.4.3" + "@babel/types" "^7.4.0" + istanbul-lib-coverage "^2.0.5" + semver "^6.0.0" + +istanbul-lib-report@^2.0.8: + version "2.0.8" + resolved "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-2.0.8.tgz" + integrity sha512-fHBeG573EIihhAblwgxrSenp0Dby6tJMFR/HvlerBsrCTD5bkUuoNtn3gVh29ZCS824cGGBPn7Sg7cNk+2xUsQ== + dependencies: + istanbul-lib-coverage "^2.0.5" + make-dir "^2.1.0" + supports-color "^6.1.0" + +istanbul-lib-source-maps@^3.0.6: + version "3.0.6" + resolved "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.6.tgz" + integrity sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw== + dependencies: + debug "^4.1.1" + istanbul-lib-coverage "^2.0.5" + make-dir "^2.1.0" + rimraf "^2.6.3" + source-map "^0.6.1" + +istanbul-reports@^2.2.4: + version "2.2.7" + resolved "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.7.tgz" + integrity sha512-uu1F/L1o5Y6LzPVSVZXNOoD/KXpJue9aeLRd0sM9uMXfZvzomB0WxVamWb5ue8kA2vVWEmW7EG+A5n3f1kqHKg== + dependencies: + html-escaper "^2.0.0" + +jose@^4.10.3: + version "4.11.1" + resolved "https://registry.yarnpkg.com/jose/-/jose-4.11.1.tgz#8f7443549befe5bddcf4bae664a9cbc1a62da4fa" + integrity sha512-YRv4Tk/Wlug8qicwqFNFVEZSdbROCHRAC6qu/i0dyNKr5JQdoa2pIGoS04lLO/jXQX7Z9omoNewYIVIxqZBd9Q== + +js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-yaml@4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz" + integrity sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q== + dependencies: + argparse "^2.0.1" + +js-yaml@^3.13.1: + version "3.14.1" + resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== dependencies: argparse "^1.0.7" - esprima "^2.6.0" + esprima "^4.0.0" -js2xmlparser@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-3.0.0.tgz#3fb60eaa089c5440f9319f51760ccd07e2499733" +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== dependencies: - xmlcreate "^1.0.1" + argparse "^2.0.1" -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - -jsdoc@^3.5.5: - version "3.5.5" - resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.5.5.tgz#484521b126e81904d632ff83ec9aaa096708fa4d" - dependencies: - babylon "7.0.0-beta.19" - bluebird "~3.5.0" - catharsis "~0.8.9" - escape-string-regexp "~1.0.5" - js2xmlparser "~3.0.0" - klaw "~2.0.0" - marked "~0.3.6" - mkdirp "~0.5.1" - requizzle "~0.2.1" - strip-json-comments "~2.0.1" +js2xmlparser@^4.0.2: + version "4.0.2" + resolved "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz" + integrity sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA== + dependencies: + xmlcreate "^2.0.4" + +jsdoc-type-pratt-parser@~2.2.3: + version "2.2.5" + resolved "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.2.5.tgz" + integrity sha512-2a6eRxSxp1BW040hFvaJxhsCMI9lT8QB8t14t+NY5tC5rckIR0U9cr2tjOeaFirmEOy6MHvmJnY7zTBHq431Lw== + +jsdoc@^3.6.7: + version "3.6.10" + resolved "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.10.tgz" + integrity sha512-IdQ8ppSo5LKZ9o3M+LKIIK8i00DIe5msDvG3G81Km+1dhy0XrOWD0Ji8H61ElgyEj/O9KRLokgKbAM9XX9CJAg== + dependencies: + "@babel/parser" "^7.9.4" + "@types/markdown-it" "^12.2.3" + bluebird "^3.7.2" + catharsis "^0.9.0" + escape-string-regexp "^2.0.0" + js2xmlparser "^4.0.2" + klaw "^4.0.1" + markdown-it "^12.3.2" + markdown-it-anchor "^8.4.1" + marked "^4.0.10" + mkdirp "^1.0.4" + requizzle "^0.2.3" + strip-json-comments "^3.1.0" taffydb "2.6.2" - underscore "~1.8.3" + underscore "~1.13.2" -json-loader@^0.5.4: - version "0.5.4" - resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de" +jsesc@^2.5.1: + version "2.5.2" + resolved "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz" + integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== -json-schema-traverse@^0.3.0: - version "0.3.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" +json-loader@^0.5.7: + version "0.5.7" + resolved "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz" + integrity sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w== -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" +json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz" + integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== + +json-parse-even-better-errors@^2.3.0: + version "2.3.1" + resolved "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz" + integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== -json-stable-stringify@^1.0.1: +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" - dependencies: - jsonify "~0.0.0" + resolved "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz" + integrity "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==" -json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: +json-stringify-safe@^5.0.1: version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + resolved "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" + integrity "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" json5@^0.5.0: version "0.5.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + resolved "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz" + integrity "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw==" -jsonify@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" +json5@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz" + integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + dependencies: + minimist "^1.2.0" -jsonpointer@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" - -jsonwebtoken@^8.3.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.3.0.tgz#056c90eee9a65ed6e6c72ddb0a1d325109aaf643" - dependencies: - jws "^3.1.5" - lodash.includes "^4.3.0" - lodash.isboolean "^3.0.3" - lodash.isinteger "^4.0.4" - lodash.isnumber "^3.0.3" - lodash.isplainobject "^4.0.6" - lodash.isstring "^4.0.1" - lodash.once "^4.0.0" - ms "^2.1.1" +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== + optionalDependencies: + graceful-fs "^4.1.6" -jsprim@^1.2.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" +jsonwebtoken@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz#d0faf9ba1cc3a56255fe49c0961a67e520c1926d" + integrity sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw== dependencies: - assert-plus "1.0.0" - extsprintf "1.0.2" - json-schema "0.2.3" - verror "1.3.6" + jws "^3.2.2" + lodash "^4.17.21" + ms "^2.1.1" + semver "^7.3.8" -jwa@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.1.6.tgz#87240e76c9808dbde18783cf2264ef4929ee50e6" +just-extend@^4.0.2: + version "4.2.1" + resolved "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz" + integrity sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg== + +jwa@^1.4.1: + version "1.4.1" + resolved "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz" + integrity sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA== dependencies: buffer-equal-constant-time "1.0.1" - ecdsa-sig-formatter "1.0.10" + ecdsa-sig-formatter "1.0.11" safe-buffer "^5.0.1" -jwks-rsa@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/jwks-rsa/-/jwks-rsa-1.3.0.tgz#f37d2a6815af17a3b2e5898ab2a41ad8c168b295" +jwks-rsa@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/jwks-rsa/-/jwks-rsa-3.0.0.tgz#5c0b298efbf4b4a47069184b2005fe94e8c088da" + integrity sha512-x9qNrP/kD6tOfrLzBVC5HaneBTR+fCEGIjwk/xSdl+KA7Tzf+R3oiY9ibrONKVLF9fR0V03enkitYPZkO65fAQ== dependencies: - "@types/express-jwt" "0.0.34" - debug "^2.2.0" - limiter "^1.1.0" - lru-memoizer "^1.6.0" - ms "^2.0.0" - request "^2.73.0" + "@types/express" "^4.17.14" + "@types/jsonwebtoken" "^8.5.9" + debug "^4.3.4" + jose "^4.10.3" + limiter "^1.1.5" + lru-memoizer "^2.1.4" -jws@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/jws/-/jws-3.1.5.tgz#80d12d05b293d1e841e7cb8b4e69e561adcf834f" +jws@^3.2.2: + version "3.2.2" + resolved "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz" + integrity sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA== dependencies: - jwa "^1.1.5" + jwa "^1.4.1" safe-buffer "^5.0.1" -kind-of@^3.0.2: +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + resolved "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz" + integrity "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==" dependencies: is-buffer "^1.1.5" kind-of@^4.0.0: version "4.0.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + resolved "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz" + integrity "sha1-IIE989cSkosgc3hpGkUGb65y3Vc= sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==" dependencies: is-buffer "^1.1.5" -klaw@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/klaw/-/klaw-2.0.0.tgz#59c128e0dc5ce410201151194eeb9cbf858650f6" - dependencies: - graceful-fs "^4.1.9" +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz" + integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== -lazy-cache@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +klaw@^4.0.1: + version "4.0.1" + resolved "https://registry.npmjs.org/klaw/-/klaw-4.0.1.tgz" + integrity sha512-pgsE40/SvC7st04AHiISNewaIMUbY5V/K8b21ekiPiFoYs/EYSdsGa+FJArB1d441uq4Q8zZyIxvAzkGNlBdRw== + +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== + dependencies: + prelude-ls "^1.2.1" + type-check "~0.4.0" levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + integrity sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA== dependencies: prelude-ls "~1.1.2" type-check "~0.3.2" -limiter@^1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/limiter/-/limiter-1.1.3.tgz#32e2eb55b2324076943e5d04c1185ffb387968ef" +limiter@^1.1.5: + version "1.1.5" + resolved "https://registry.npmjs.org/limiter/-/limiter-1.1.5.tgz" + integrity sha512-FWWMIEOxz3GwUI4Ts/IvgVy6LPvoMPgjMdQ185nN6psJyBJ4yOpzqm695/h5umdLJg2vW3GR5iG11MAkR2AzJA== + +lines-and-columns@^1.1.6: + version "1.2.4" + resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz" + integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== + +linkify-it@^3.0.1: + version "3.0.3" + resolved "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz" + integrity sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ== + dependencies: + uc.micro "^1.0.1" + +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz" + integrity "sha1-L19Fq5HjMhYjT9U62rZo607AmTs= sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==" + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" -loader-utils@^0.2.11, loader-utils@^0.2.5, loader-utils@~0.2.2, loader-utils@~0.2.3, loader-utils@~0.2.5: +loader-runner@^2.4.0: + version "2.4.0" + resolved "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz" + integrity sha512-Jsmr89RcXGIwivFY21FcRrisYZfvLMTWx5kOLc+JTxtpBOG6xML0vzbc6SEQG2FO9/4Fc3wW4LVcB5DmGflaRw== + +loader-utils@^0.2.5, loader-utils@~0.2.2, loader-utils@~0.2.3, loader-utils@~0.2.5: version "0.2.17" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" + resolved "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz" + integrity "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g= sha512-tiv66G0SmiOx+pLWMtGEkfSEejxvb6N6uRrQjfWJIT79W9GMpgKeCAmm9aVBKtd4WEgntciI8CsGqjpDoCWJug==" dependencies: big.js "^3.1.3" emojis-list "^2.0.0" json5 "^0.5.0" object-assign "^4.0.1" +loader-utils@^1.2.3: + version "1.4.0" + resolved "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz" + integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA== + dependencies: + big.js "^5.2.2" + emojis-list "^3.0.0" + json5 "^1.0.1" + locate-path@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + resolved "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz" + integrity "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==" dependencies: p-locate "^2.0.0" path-exists "^3.0.0" -lock@~0.1.2: - version "0.1.4" - resolved "https://registry.yarnpkg.com/lock/-/lock-0.1.4.tgz#fec7deaef17e7c3a0a55e1da042803e25d91745d" - -lodash.includes@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" - -lodash.isboolean@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" - -lodash.isinteger@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" -lodash.isnumber@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" -lodash.isplainobject@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" -lodash.isstring@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz" + integrity "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" -lodash.once@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" +lodash.flattendeep@^4.4.0: + version "4.4.0" + resolved "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz" + integrity "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==" -lodash@2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-2.4.1.tgz#5b7723034dda4d262e5a46fb2c58d7cc22f71420" +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz" + integrity "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==" -lodash@^4.17.4: - version "4.17.10" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" +lodash.merge@^4.6.2: + version "4.6.2" + resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash@~4.5.1: - version "4.5.1" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.5.1.tgz#80e8a074ca5f3893a6b1c10b2a636492d710c316" +lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.21: + version "4.17.21" + resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== -lolex@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" +log-symbols@4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz" + integrity sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA== + dependencies: + chalk "^4.0.0" -longest@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" +loupe@^2.3.1: + version "2.3.4" + resolved "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz" + integrity sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ== + dependencies: + get-func-name "^2.0.0" lower-case-first@^1.0.0: version "1.0.2" - resolved "https://registry.yarnpkg.com/lower-case-first/-/lower-case-first-1.0.2.tgz#e5da7c26f29a7073be02d52bac9980e5922adfa1" + resolved "https://registry.npmjs.org/lower-case-first/-/lower-case-first-1.0.2.tgz" + integrity "sha1-5dp8JvKacHO+AtUrrJmA5ZIq36E= sha512-UuxaYakO7XeONbKrZf5FEgkantPf5DUqDayzP5VXZrtRPdH86s4kN47I8B3TW10S4QKiE3ziHNf3kRN//okHjA==" dependencies: lower-case "^1.1.2" lower-case@^1.1.0, lower-case@^1.1.1, lower-case@^1.1.2: version "1.1.4" - resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac" - -lru-cache@2: - version "2.7.3" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" - -lru-cache@^4.0.1: - version "4.1.2" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.2.tgz#45234b2e6e2f2b33da125624c4664929a0224c3f" - dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" - -lru-cache@~2.6.5: - version "2.6.5" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.6.5.tgz#e56d6354148ede8d7707b58d143220fd08df0fd5" + resolved "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz" + integrity "sha1-miyr0bno4K6ZOkv31YdcOcQujqw= sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==" -lru-cache@~4.0.0: +lru-cache@^4.0.1, lru-cache@~4.0.0: version "4.0.2" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e" + resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-4.0.2.tgz" + integrity "sha1-HRdnnAac2l0ECZGgnbwsDbN35V4= sha512-uQw9OqphAGiZhkuPlpFGmdTU2tEuhxTourM/19qGJrxBPHAr/f8BT1a0i/lOclESnGatdJG/UCkP9kZB/Lh1iw==" dependencies: pseudomap "^1.0.1" yallist "^2.0.0" -lru-memoizer@^1.11.1: - version "1.11.1" - resolved "https://registry.yarnpkg.com/lru-memoizer/-/lru-memoizer-1.11.1.tgz#0693f6100593914c02e192bf9b8d93884cbf50d3" +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== dependencies: - lock "~0.1.2" - lodash "~4.5.1" - lru-cache "~4.0.0" - very-fast-args "^1.1.0" + yallist "^3.0.2" + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" -lru-memoizer@^1.6.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/lru-memoizer/-/lru-memoizer-1.12.0.tgz#efe65706cc8a9cc653f80f0d5a6ea38ad950e352" +lru-memoizer@^2.1.4: + version "2.1.4" + resolved "https://registry.npmjs.org/lru-memoizer/-/lru-memoizer-2.1.4.tgz" + integrity sha512-IXAq50s4qwrOBrXJklY+KhgZF+5y98PDaNo0gi/v2KQBFLyWr+JyFvijZXkGKjQj/h9c0OwoE+JZbwUXce76hQ== dependencies: - lock "~0.1.2" - lodash "^4.17.4" + lodash.clonedeep "^4.5.0" lru-cache "~4.0.0" - very-fast-args "^1.1.0" -marked@~0.3.6: - version "0.3.6" - resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.6.tgz#b2c6c618fccece4ef86c4fc6cb8a7cbf5aeda8d7" +make-dir@^2.0.0, make-dir@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz" + integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== + dependencies: + pify "^4.0.1" + semver "^5.6.0" -md5@^2.1.0, md5@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9" +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz" + integrity "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==" + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz" + integrity "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==" + dependencies: + object-visit "^1.0.0" + +markdown-it-anchor@^8.4.1: + version "8.6.4" + resolved "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.4.tgz" + integrity sha512-Ul4YVYZNxMJYALpKtu+ZRdrryYt/GlQ5CK+4l1bp/gWXOG2QWElt6AqF3Mih/wfUKdZbNAZVXGR73/n6U/8img== + +markdown-it@^12.3.2: + version "12.3.2" + resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz" + integrity sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg== + dependencies: + argparse "^2.0.1" + entities "~2.1.0" + linkify-it "^3.0.1" + mdurl "^1.0.1" + uc.micro "^1.0.5" + +marked@^4.0.10: + version "4.0.16" + resolved "https://registry.npmjs.org/marked/-/marked-4.0.16.tgz" + integrity sha512-wahonIQ5Jnyatt2fn8KqF/nIqZM8mh3oRu2+l5EANGMhu6RFjiSG52QNE2eWzFMI94HqYSgN184NurgNG6CztA== + +md5.js@^1.3.4: + version "1.3.5" + resolved "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz" + integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +md5@^2.1.0: + version "2.3.0" + resolved "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz" + integrity sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g== dependencies: - charenc "~0.0.1" - crypt "~0.0.1" - is-buffer "~1.1.1" + charenc "0.0.2" + crypt "0.0.2" + is-buffer "~1.1.6" -memory-fs@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290" +mdurl@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz" + integrity "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4= sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==" -memory-fs@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.3.0.tgz#7bcc6b629e3a43e871d7e29aca6ae8a7f15cbb20" +memory-fs@^0.4.1: + version "0.4.1" + resolved "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz" + integrity "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI= sha512-cda4JKCxReDXFXRqOHPQscuIYg1PvxbE2S2GP45rnwfEK+vZaXC8C1OFvdHIbgw0DLzowXGVoxLaAmlgRy14GQ==" + dependencies: + errno "^0.1.3" + readable-stream "^2.0.1" + +memory-fs@^0.5.0: + version "0.5.0" + resolved "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz" + integrity sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA== dependencies: errno "^0.1.3" readable-stream "^2.0.1" merge-descriptors@~1.0.0: version "1.0.1" - resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" - -methods@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" - -micromatch@^2.1.5: - version "2.3.11" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" - dependencies: - arr-diff "^2.0.0" - array-unique "^0.2.1" - braces "^1.8.2" - expand-brackets "^0.1.4" - extglob "^0.3.1" - filename-regex "^2.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.1" - kind-of "^3.0.2" - normalize-path "^2.0.1" - object.omit "^2.0.0" - parse-glob "^3.0.4" - regex-cache "^0.4.2" - -mime-db@~1.27.0: - version "1.27.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" - -mime-db@~1.30.0: - version "1.30.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" - -mime-db@~1.35.0: - version "1.35.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.35.0.tgz#0569d657466491283709663ad379a99b90d9ab47" + resolved "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz" + integrity "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E= sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" -mime-types@^2.1.12, mime-types@~2.1.7: - version "2.1.15" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" +merge-source-map@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz" + integrity sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw== dependencies: - mime-db "~1.27.0" + source-map "^0.6.1" -mime-types@~2.1.17: - version "2.1.17" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" +methods@^1.1.2: + version "1.1.2" + resolved "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz" + integrity "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==" + +micromatch@^3.1.10, micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +miller-rabin@^4.0.0: + version "4.0.1" + resolved "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz" + integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== dependencies: - mime-db "~1.30.0" + bn.js "^4.0.0" + brorand "^1.0.1" + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@~2.1.19: - version "2.1.19" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.19.tgz#71e464537a7ef81c15f2db9d97e913fc0ff606f0" +mime-types@^2.1.12: + version "2.1.35" + resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== dependencies: - mime-db "~1.35.0" + mime-db "1.52.0" -mime@^1.4.1: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" +mime@^2.4.6: + version "2.6.0" + resolved "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz" + integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== minami@^1.2.3: version "1.2.3" - resolved "https://registry.yarnpkg.com/minami/-/minami-1.2.3.tgz#99b6dcdfb2f0a54da1c9c8f7aa3a327787aaf9f8" + resolved "https://registry.npmjs.org/minami/-/minami-1.2.3.tgz" + integrity "sha1-mbbc37LwpU2hycj3qjoyd4eq+fg= sha512-3f2QqqbUC1usVux0FkQMFYB73yd9JIxmHSn1dWQacizL6hOUaNu6mA3KxZ9SfiCc4qgcgq+5XP59+hP7URa1Dw==" -minimatch@0.3: - version "0.3.0" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd" - dependencies: - lru-cache "2" - sigmund "~1.0.0" +minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimalistic-crypto-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz" + integrity "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" -"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: +minimatch@3.0.4: version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== dependencies: brace-expansion "^1.1.7" -minimist@0.0.8, minimist@~0.0.1: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" +minimatch@^3.0.4, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" -minimist@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" +minimist@^1.2.0, minimist@^1.2.6: + version "1.2.6" + resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== -mkdirp@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" +mississippi@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/mississippi/-/mississippi-3.0.0.tgz" + integrity sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA== + dependencies: + concat-stream "^1.5.0" + duplexify "^3.4.2" + end-of-stream "^1.1.0" + flush-write-stream "^1.0.0" + from2 "^2.1.0" + parallel-transform "^1.1.0" + pump "^3.0.0" + pumpify "^1.3.3" + stream-each "^1.1.0" + through2 "^2.0.0" + +mixin-deep@^1.2.0: + version "1.3.2" + resolved "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" -mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" +mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@~0.5.1: + version "0.5.6" + resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== dependencies: - minimist "0.0.8" + minimist "^1.2.6" + +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== -mocha-junit-reporter@^1.13.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/mocha-junit-reporter/-/mocha-junit-reporter-1.13.0.tgz#030db8c530b244667253b03861d4cd336f7e56c8" +mocha-junit-reporter@^2.0.0: + version "2.0.2" + resolved "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-2.0.2.tgz" + integrity sha512-vYwWq5hh3v1lG0gdQCBxwNipBfvDiAM1PHroQRNp96+2l72e9wEUTw+mzoK+O0SudgfQ7WvTQZ9Nh3qkAYAjfg== dependencies: debug "^2.2.0" md5 "^2.1.0" mkdirp "~0.5.1" + strip-ansi "^6.0.1" xml "^1.0.0" -mocha-multi@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/mocha-multi/-/mocha-multi-0.11.0.tgz#5cd48e04dbe7657d7e997880c4ccd021aaf51aa5" - dependencies: - debug "~0.7.4" - is-string "^1.0.4" - mkdirp "^0.5.1" - object-assign "^4.1.1" - -mocha@^2.2.4: - version "2.5.3" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-2.5.3.tgz#161be5bdeb496771eb9b35745050b622b5aefc58" - dependencies: - commander "2.3.0" - debug "2.2.0" - diff "1.4.0" - escape-string-regexp "1.0.2" - glob "3.2.11" - growl "1.9.2" - jade "0.26.3" - mkdirp "0.5.1" - supports-color "1.2.0" - to-iso-string "0.0.2" - -module-not-found-error@^1.0.0: +mocha@^8.4.0: + version "8.4.0" + resolved "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz" + integrity sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ== + dependencies: + "@ungap/promise-all-settled" "1.1.2" + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.1" + debug "4.3.1" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.1.6" + growl "1.10.5" + he "1.2.0" + js-yaml "4.0.0" + log-symbols "4.0.0" + minimatch "3.0.4" + ms "2.1.3" + nanoid "3.1.20" + serialize-javascript "5.0.1" + strip-json-comments "3.1.1" + supports-color "8.1.1" + which "2.0.2" + wide-align "1.1.3" + workerpool "6.1.0" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +module-not-found-error@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/module-not-found-error/-/module-not-found-error-1.0.1.tgz#cf8b4ff4f29640674d6cdd02b0e3bc523c2bbdc0" + resolved "https://registry.npmjs.org/module-not-found-error/-/module-not-found-error-1.0.1.tgz" + integrity "sha1-z4tP9PKWQGdNbN0CsOO8UjwrvcA= sha512-pEk4ECWQXV6z2zjhRZUongnLJNUeGQJ3w6OQ5ctGwD+i5o93qjRQUk2Rt6VdNeu3sEP0AB4LcfvdebpxBRVr4g==" -moment@^2.18.1: - version "2.18.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" +move-concurrently@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz" + integrity "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I= sha512-hdrFxZOycD/g6A6SoI2bB5NA/5NEqD0569+S47WZhPvm46sD50ZHdYaFmnua5lndde9rCHGjmfK7Z8BuCt/PcQ==" + dependencies: + aproba "^1.1.1" + copy-concurrently "^1.0.0" + fs-write-stream-atomic "^1.0.8" + mkdirp "^0.5.1" + rimraf "^2.5.4" + run-queue "^1.0.3" mri@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.0.tgz#5c0a3f29c8ccffbbb1ec941dcec09d71fa32f36a" - -ms@0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + version "1.2.0" + resolved "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz" + integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA== ms@2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + resolved "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" + integrity "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" -ms@^2.0.0, ms@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" +ms@2.1.2, ms@^2.1.1: + version "2.1.2" + resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@2.1.3: + version "2.1.3" + resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +multimatch@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/multimatch/-/multimatch-3.0.0.tgz" + integrity sha512-22foS/gqQfANZ3o+W7ST2x25ueHDVNWl/b9OlGcLpy/iKxjCpvcNCM51YCenUi7Mt/jAjjqv8JwZRs8YP5sRjA== + dependencies: + array-differ "^2.0.3" + array-union "^1.0.2" + arrify "^1.0.1" + minimatch "^3.0.4" + +nan@^2.12.1: + version "2.15.0" + resolved "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz" + integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== + +nanoid@3.1.20: + version "3.1.20" + resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz" + integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw== + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz" + integrity "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" -nan@^2.3.0: +neo-async@^2.5.0, neo-async@^2.6.1: version "2.6.2" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" + resolved "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz" + integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== -netmask@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35" +nested-error-stacks@^2.0.0: + version "2.1.1" + resolved "https://registry.npmjs.org/nested-error-stacks/-/nested-error-stacks-2.1.1.tgz" + integrity sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw== -nock@^3.1.1: - version "3.6.0" - resolved "https://registry.yarnpkg.com/nock/-/nock-3.6.0.tgz#d26c40004b3449a655b91b74ae3c56fc02c84525" +netmask@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7" + integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg== + +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + +nise@^5.1.1: + version "5.1.1" + resolved "https://registry.npmjs.org/nise/-/nise-5.1.1.tgz" + integrity sha512-yr5kW2THW1AkxVmCnKEh4nbYkJdB3I7LUkiUgOvEkOp414mc2UMaHMA7pjq1nYowhdoJZGwEKGaQVbxfpWj10A== dependencies: - chai ">=1.9.2 <4.0.0" - debug "^2.2.0" - deep-equal "^1.0.0" + "@sinonjs/commons" "^1.8.3" + "@sinonjs/fake-timers" ">=5" + "@sinonjs/text-encoding" "^0.7.1" + just-extend "^4.0.2" + path-to-regexp "^1.7.0" + +nock@^13.2.7: + version "13.2.7" + resolved "https://registry.npmjs.org/nock/-/nock-13.2.7.tgz" + integrity sha512-R6NUw7RIPtKwgK7jskuKoEi4VFMqIHtV2Uu9K/Uegc4TA5cqe+oNMYslZcUmnVNQCTG6wcSqUBaGTDd7sq5srg== + dependencies: + debug "^4.1.0" json-stringify-safe "^5.0.1" - lodash "2.4.1" - mkdirp "^0.5.0" - propagate "0.3.x" + lodash "^4.17.21" + propagate "^2.0.0" -node-libs-browser@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-0.7.0.tgz#3e272c0819e308935e26674408d7af0e1491b83b" +node-libs-browser@^2.2.1: + version "2.2.1" + resolved "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz" + integrity sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q== dependencies: assert "^1.1.1" - browserify-zlib "^0.1.4" - buffer "^4.9.0" + browserify-zlib "^0.2.0" + buffer "^4.3.0" console-browserify "^1.1.0" constants-browserify "^1.0.0" - crypto-browserify "3.3.0" + crypto-browserify "^3.11.0" domain-browser "^1.1.1" - events "^1.0.0" - https-browserify "0.0.1" - os-browserify "^0.2.0" - path-browserify "0.0.0" - process "^0.11.0" + events "^3.0.0" + https-browserify "^1.0.0" + os-browserify "^0.3.0" + path-browserify "0.0.1" + process "^0.11.10" punycode "^1.2.4" querystring-es3 "^0.2.0" - readable-stream "^2.0.5" + readable-stream "^2.3.3" stream-browserify "^2.0.1" - stream-http "^2.3.1" - string_decoder "^0.10.25" - timers-browserify "^2.0.2" + stream-http "^2.7.2" + string_decoder "^1.0.0" + timers-browserify "^2.0.4" tty-browserify "0.0.0" url "^0.11.0" - util "^0.10.3" - vm-browserify "0.0.4" + util "^0.11.0" + vm-browserify "^1.0.1" -node-pre-gyp@^0.6.36: - version "0.6.36" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" +normalize-package-data@^2.3.2, normalize-package-data@^2.5.0: + version "2.5.0" + resolved "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== dependencies: - mkdirp "^0.5.1" - nopt "^4.0.1" - npmlog "^4.0.2" - rc "^1.1.7" - request "^2.81.0" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^2.2.1" - tar-pack "^3.4.0" - -nopt@3.x: - version "3.0.6" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" - dependencies: - abbrev "1" - -nopt@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" - dependencies: - abbrev "1" - osenv "^0.1.4" - -normalize-path@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-1.0.0.tgz#32d0e472f91ff345701c15a8311018d3b0a90379" + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" -normalize-path@^2.0.1: +normalize-path@^2.1.1: version "2.1.1" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz" + integrity "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk= sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==" dependencies: remove-trailing-separator "^1.0.1" +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + npm-run-path@^2.0.0: version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + resolved "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz" + integrity "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==" dependencies: path-key "^2.0.0" -npmlog@^4.0.2: - version "4.1.0" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" - dependencies: - are-we-there-yet "~1.1.2" - console-control-strings "~1.1.0" - gauge "~2.7.3" - set-blocking "~2.0.0" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - -oauth-sign@~0.8.1, oauth-sign@~0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" - -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" +nyc@^14.1.1: + version "14.1.1" + resolved "https://registry.npmjs.org/nyc/-/nyc-14.1.1.tgz" + integrity sha512-OI0vm6ZGUnoGZv/tLdZ2esSVzDwUC88SNs+6JoSOMVxA+gKMB8Tk7jBwgemLx4O40lhhvZCVw1C+OYLOBOPXWw== + dependencies: + archy "^1.0.0" + caching-transform "^3.0.2" + convert-source-map "^1.6.0" + cp-file "^6.2.0" + find-cache-dir "^2.1.0" + find-up "^3.0.0" + foreground-child "^1.5.6" + glob "^7.1.3" + istanbul-lib-coverage "^2.0.5" + istanbul-lib-hook "^2.0.7" + istanbul-lib-instrument "^3.3.0" + istanbul-lib-report "^2.0.8" + istanbul-lib-source-maps "^3.0.6" + istanbul-reports "^2.2.4" + js-yaml "^3.13.1" + make-dir "^2.1.0" + merge-source-map "^1.1.0" + resolve-from "^4.0.0" + rimraf "^2.6.3" + signal-exit "^3.0.2" + spawn-wrap "^1.4.2" + test-exclude "^5.2.3" + uuid "^3.3.2" + yargs "^13.2.2" + yargs-parser "^13.0.0" -object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: +object-assign@^4.0.1, object-assign@^4.1.1: version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz" + integrity "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" -object-keys@^1.0.10, object-keys@^1.0.8: - version "1.0.11" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz" + integrity "sha1-fn2Fi3gb18mRpBupde04EnVOmYw= sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==" + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" -object.assign@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.0.4.tgz#b1c9cc044ef1b9fe63606fc141abbb32e14730cc" +object-inspect@^1.9.0: + version "1.12.1" + resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.1.tgz" + integrity sha512-Y/jF6vnvEtOPGiKD1+q+X0CiUYRQtEHp89MLLUJ7TUivtH8Ugn2+3A7Rynqk7BRsAoqeOQWnFnjpDrKSxDgIGA== + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz" + integrity "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==" dependencies: - define-properties "^1.1.2" - function-bind "^1.1.0" - object-keys "^1.0.10" + isobject "^3.0.0" -object.omit@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz" + integrity "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==" dependencies: - for-own "^0.1.4" - is-extendable "^0.1.1" + isobject "^3.0.1" -once@1.x, once@^1.3.0, once@^1.3.3: +once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" + integrity "sha1-WDsap3WWHUsROsF9nFC6753Xa9E= sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==" dependencies: wrappy "1" -optimist@^0.6.1, optimist@~0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" - dependencies: - minimist "~0.0.1" - wordwrap "~0.0.2" +opencollective-postinstall@^2.0.2: + version "2.0.3" + resolved "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz" + integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q== optionator@^0.8.1: - version "0.8.2" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + version "0.8.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" + integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== dependencies: deep-is "~0.1.3" - fast-levenshtein "~2.0.4" + fast-levenshtein "~2.0.6" levn "~0.3.0" prelude-ls "~1.1.2" type-check "~0.3.2" - wordwrap "~1.0.0" + word-wrap "~1.2.3" -os-browserify@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.2.1.tgz#63fc4ccee5d2d7763d26bbf8601078e6c2e0044f" +optionator@^0.9.1: + version "0.9.1" + resolved "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz" + integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== + dependencies: + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + word-wrap "^1.2.3" -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" +os-browserify@^0.3.0: + version "0.3.0" + resolved "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz" + integrity "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A==" -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: +os-homedir@^1.0.1: version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - -osenv@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.0" + resolved "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz" + integrity "sha1-/7xJiDNuDoM94MFox+8VISGqf7M= sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==" p-finally@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + resolved "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz" + integrity "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==" p-limit@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.2.0.tgz#0e92b6bedcb59f022c13d0f1949dc82d15909f1c" + version "1.3.0" + resolved "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz" + integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== dependencies: p-try "^1.0.0" +p-limit@^2.0.0, p-limit@^2.2.0: + version "2.3.0" + resolved "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + p-locate@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + resolved "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz" + integrity "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==" dependencies: p-limit "^1.1.0" +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + p-try@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + resolved "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz" + integrity "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==" -pac-proxy-agent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-2.0.0.tgz#beb17cd2b06a20b379d57e1b2e2c29be0dfe5f9a" - dependencies: - agent-base "^2.1.1" - debug "^2.6.8" - get-uri "^2.0.0" - http-proxy-agent "^1.0.0" - https-proxy-agent "^1.0.0" - pac-resolver "^3.0.0" +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +pac-proxy-agent@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz#b718f76475a6a5415c2efbe256c1c971c84f635e" + integrity sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ== + dependencies: + "@tootallnate/once" "1" + agent-base "6" + debug "4" + get-uri "3" + http-proxy-agent "^4.0.1" + https-proxy-agent "5" + pac-resolver "^5.0.0" raw-body "^2.2.0" - socks-proxy-agent "^3.0.0" + socks-proxy-agent "5" -pac-resolver@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-3.0.0.tgz#6aea30787db0a891704deb7800a722a7615a6f26" +pac-resolver@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-5.0.1.tgz#c91efa3a9af9f669104fa2f51102839d01cde8e7" + integrity sha512-cy7u00ko2KVgBAjuhevqpPeHIkCIqPe1v24cydhWjmeuzaBfmUWFCZJ1iAh5TuVzVZoUzXIW7K8sMYOZ84uZ9Q== dependencies: - co "^4.6.0" - degenerator "^1.0.4" + degenerator "^3.0.2" ip "^1.1.5" - netmask "^1.0.6" - thunkify "^2.1.2" + netmask "^2.0.2" -pako@~0.2.0: - version "0.2.9" - resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75" +package-hash@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/package-hash/-/package-hash-3.0.0.tgz" + integrity sha512-lOtmukMDVvtkL84rJHI7dpTYq+0rli8N2wlnqUcBuDWCfVhRUfOmnR9SsoHFMLpACvEV60dX7rd0rFaYDZI+FA== + dependencies: + graceful-fs "^4.1.15" + hasha "^3.0.0" + lodash.flattendeep "^4.4.0" + release-zalgo "^1.0.0" + +pako@~1.0.5: + version "1.0.11" + resolved "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz" + integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== + +parallel-transform@^1.1.0: + version "1.2.0" + resolved "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.2.0.tgz" + integrity sha512-P2vSmIu38uIlvdcU7fDkyrxj33gTUy/ABO5ZUbGowxNCopBq/OoD42bP4UmMrJoPyk4Uqf0mu3mtWBhHCZD8yg== + dependencies: + cyclist "^1.0.1" + inherits "^2.0.3" + readable-stream "^2.1.5" param-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/param-case/-/param-case-1.1.2.tgz#dcb091a43c259b9228f1c341e7b6a44ea0bf9743" + resolved "https://registry.npmjs.org/param-case/-/param-case-1.1.2.tgz" + integrity "sha1-3LCRpDwlm5Io8cNB57akTqC/l0M= sha512-gksk6zeZQxwBm1AHsKh+XDFsTGf1LvdZSkkpSIkfDtzW+EQj/P2PBgNb3Cs0Y9Xxqmbciv2JZe3fWU6Xbher+Q==" dependencies: sentence-case "^1.1.2" -parse-glob@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" +parent-module@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz" + integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== + dependencies: + callsites "^3.0.0" + +parse-asn1@^5.0.0, parse-asn1@^5.1.5: + version "5.1.6" + resolved "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz" + integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== + dependencies: + asn1.js "^5.2.0" + browserify-aes "^1.0.0" + evp_bytestokey "^1.0.0" + pbkdf2 "^3.0.3" + safe-buffer "^5.1.1" + +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz" + integrity "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==" + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + +parse-json@^5.0.0: + version "5.2.0" + resolved "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz" + integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== dependencies: - glob-base "^0.3.0" - is-dotfile "^1.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.0" + "@babel/code-frame" "^7.0.0" + error-ex "^1.3.1" + json-parse-even-better-errors "^2.3.0" + lines-and-columns "^1.1.6" pascal-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/pascal-case/-/pascal-case-1.1.2.tgz#3e5d64a20043830a7c49344c2d74b41be0c9c99b" + resolved "https://registry.npmjs.org/pascal-case/-/pascal-case-1.1.2.tgz" + integrity "sha1-Pl1kogBDgwp8STRMLXS0G+DJyZs= sha512-QWlbdQHdKWlcyTEuv/M0noJtlCa7qTmg5QFAqhx5X9xjAfCU1kXucL+rcOmd2HliESuRLIOz8521RAW/yhuQog==" dependencies: camel-case "^1.1.1" upper-case-first "^1.1.0" -path-browserify@0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a" +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz" + integrity "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==" + +path-browserify@0.0.1: + version "0.0.1" + resolved "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz" + integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== path-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/path-case/-/path-case-1.1.2.tgz#50ce6ba0d3bed3dd0b5c2a9c4553697434409514" + resolved "https://registry.npmjs.org/path-case/-/path-case-1.1.2.tgz" + integrity "sha1-UM5roNO+090LXCqcRVNpdDRAlRQ= sha512-2snAGA6xVRqTuTPa40bn0iEpYtVK6gEqeyS/63dqpm5pGlesOv6EmRcnB9Rr6eAnAC2Wqlbz0tqgJZryttxhxg==" dependencies: sentence-case "^1.1.2" +path-dirname@^1.0.0: + version "1.0.2" + resolved "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz" + integrity "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= sha512-ALzNPpyNq9AqXMBjeymIjFDAkAFH06mHJH/cSBHAgU0s4vfpBn6b2nf8tiRLvagKD8RbTpq2FKTBg7cl9l3c7Q==" + path-exists@^3.0.0: version "3.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + resolved "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz" + integrity "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==" + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== path-is-absolute@^1.0.0: version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" + integrity "sha1-F0uSaHNVNP+8es5r9TpanhtcX18= sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" -path-key@^2.0.0: +path-key@^2.0.0, path-key@^2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + resolved "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz" + integrity "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==" -path-parse@^1.0.5: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -pbkdf2-compat@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pbkdf2-compat/-/pbkdf2-compat-2.0.1.tgz#b6e0c8fa99494d94e0511575802a59a5c142f288" +path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== -pem@^1.13.1: - version "1.13.1" - resolved "https://registry.yarnpkg.com/pem/-/pem-1.13.1.tgz#57dd3e0c044fbcf709db026a737e1aad7dc8330f" +path-to-regexp@^1.7.0: + version "1.8.0" + resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz" + integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA== dependencies: - es6-promisify "^6.0.0" - md5 "^2.2.1" - os-tmpdir "^1.0.1" - which "^1.3.1" + isarray "0.0.1" -performance-now@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz" + integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== + dependencies: + pify "^3.0.0" -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" +pathval@^1.1.1: + version "1.1.1" + resolved "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== -pinkie-promise@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" +pbkdf2@^3.0.3: + version "3.1.2" + resolved "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz" + integrity sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA== dependencies: - pinkie "^2.0.0" + create-hash "^1.1.2" + create-hmac "^1.1.4" + ripemd160 "^2.0.1" + safe-buffer "^5.0.1" + sha.js "^2.4.8" -pinkie@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz" + integrity "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==" + +pify@^4.0.1: + version "4.0.1" + resolved "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz" + integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== + +pkg-dir@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz" + integrity sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw== + dependencies: + find-up "^3.0.0" + +pkg-dir@^4.2.0: + version "4.2.0" + resolved "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + +please-upgrade-node@^3.2.0: + version "3.2.0" + resolved "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz" + integrity sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg== + dependencies: + semver-compare "^1.0.0" + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz" + integrity "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==" + +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== -preserve@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" -prettier@^1.12.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.0.tgz#d26fc5894b9230de97629b39cae225b503724ce8" +prettier@2.4.1: + version "2.4.1" + resolved "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz" + integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA== -pretty-quick@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-1.4.1.tgz#9d41f778d2d4d940ec603d1293a0998e84c4722c" +pretty-quick@^1.11.1: + version "1.11.1" + resolved "https://registry.npmjs.org/pretty-quick/-/pretty-quick-1.11.1.tgz" + integrity sha512-kSXCkcETfak7EQXz6WOkCeCqpbC4GIzrN/vaneTGMP/fAtD8NerA9bPhCUqHAks1geo7biZNl5uEMPceeneLuA== dependencies: chalk "^2.3.0" execa "^0.8.0" find-up "^2.1.0" ignore "^3.3.7" mri "^1.1.0" + multimatch "^3.0.0" -process-nextick-args@~1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== -process@^0.11.0: +process@^0.11.10: version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + resolved "https://registry.npmjs.org/process/-/process-0.11.10.tgz" + integrity "sha1-czIwDoQBYb2j5podHZGn1LwW8YI= sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==" -propagate@0.3.x: - version "0.3.1" - resolved "https://registry.yarnpkg.com/propagate/-/propagate-0.3.1.tgz#e3a84404a7ece820dd6bbea9f6d924e3135ae09c" +promise-inflight@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz" + integrity "sha1-mEcocL8igTL8vdhoEputEsPAKeM= sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==" -proxy-agent@2: - version "2.1.0" - resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-2.1.0.tgz#a3a2b3866debfeb79bb791f345dc9bc876e7ff86" - dependencies: - agent-base "2" - debug "2" - extend "3" - http-proxy-agent "1" - https-proxy-agent "1" - lru-cache "~2.6.5" - pac-proxy-agent "^2.0.0" - socks-proxy-agent "2" - -proxyquire@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/proxyquire/-/proxyquire-2.1.0.tgz#c2263a38bf0725f2ae950facc130e27510edce8d" +propagate@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz" + integrity sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag== + +proxy-agent@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-5.0.0.tgz#d31405c10d6e8431fde96cba7a0c027ce01d633b" + integrity sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g== + dependencies: + agent-base "^6.0.0" + debug "4" + http-proxy-agent "^4.0.0" + https-proxy-agent "^5.0.0" + lru-cache "^5.1.1" + pac-proxy-agent "^5.0.0" + proxy-from-env "^1.0.0" + socks-proxy-agent "^5.0.0" + +proxy-from-env@^1.0.0: + version "1.1.0" + resolved "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + +proxyquire@^2.1.3: + version "2.1.3" + resolved "https://registry.npmjs.org/proxyquire/-/proxyquire-2.1.3.tgz" + integrity sha512-BQWfCqYM+QINd+yawJz23tbBM40VIGXOdDw3X344KcclI/gtBbdWF6SlQ4nK/bYhF9d27KYug9WzljHC6B9Ysg== dependencies: fill-keys "^1.0.2" - module-not-found-error "^1.0.0" - resolve "~1.8.1" + module-not-found-error "^1.0.1" + resolve "^1.11.1" -prr@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a" +prr@~1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz" + integrity "sha1-0/wRS6BplaRexok/SEzrHXj19HY= sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==" -pseudomap@^1.0.1, pseudomap@^1.0.2: +pseudomap@^1.0.1: version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + resolved "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz" + integrity "sha1-8FKijacOYYkX7wqKw0wa5aaChrM= sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==" + +public-encrypt@^4.0.0: + version "4.0.3" + resolved "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz" + integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== + dependencies: + bn.js "^4.1.0" + browserify-rsa "^4.0.0" + create-hash "^1.1.0" + parse-asn1 "^5.0.0" + randombytes "^2.0.1" + safe-buffer "^5.1.2" + +pump@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz" + integrity sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +pump@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz" + integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" -psl@^1.1.24: - version "1.1.29" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.29.tgz#60f580d360170bb722a797cc704411e6da850c67" +pumpify@^1.3.3: + version "1.5.1" + resolved "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz" + integrity sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ== + dependencies: + duplexify "^3.6.0" + inherits "^2.0.3" + pump "^2.0.0" punycode@1.3.2: version "1.3.2" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + resolved "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz" + integrity "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==" -punycode@^1.2.4, punycode@^1.4.1: +punycode@^1.2.4: version "1.4.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - -qs@^6.5.1, qs@~6.5.1: - version "6.5.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + resolved "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz" + integrity "sha1-wNWmOycYgArY4esPpSachN1BhF4= sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==" -qs@~6.3.0: - version "6.3.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" - -qs@~6.4.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" +punycode@^2.1.0: + version "2.1.1" + resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -qs@~6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" +qs@^6.9.4: + version "6.10.3" + resolved "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz" + integrity sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ== + dependencies: + side-channel "^1.0.4" querystring-es3@^0.2.0: version "0.2.1" - resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" + resolved "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz" + integrity "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM= sha512-773xhDQnZBMFobEiztv8LIl70ch5MSF/jUQVlhwFyBILqq96anmoctVIYz+ZRp0qbCKATTn6ev02M3r7Ga5vqA==" querystring@0.2.0: version "0.2.0" - resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + resolved "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz" + integrity "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==" -randomatic@^1.1.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" +randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== dependencies: - is-number "^3.0.0" - kind-of "^4.0.0" + safe-buffer "^5.1.0" + +randomfill@^1.0.3: + version "1.0.4" + resolved "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz" + integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== + dependencies: + randombytes "^2.0.5" + safe-buffer "^5.1.0" raw-body@^2.2.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" + version "2.5.1" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.1.tgz#fe1b1628b181b700215e5fd42389f98b71392857" + integrity sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig== dependencies: - bytes "3.0.0" - http-errors "1.6.2" - iconv-lite "0.4.19" + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" unpipe "1.0.0" -rc@^1.1.7: - version "1.2.1" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" +read-pkg-up@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-4.0.0.tgz" + integrity sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA== dependencies: - deep-extend "~0.4.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" + find-up "^3.0.0" + read-pkg "^3.0.0" -readable-stream@1.1.x: - version "1.1.14" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz" + integrity "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==" dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" -readable-stream@2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" +read-pkg@^5.2.0: + version "5.2.0" + resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz" + integrity sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg== + dependencies: + "@types/normalize-package-data" "^2.4.0" + normalize-package-data "^2.5.0" + parse-json "^5.0.0" + type-fest "^0.6.0" + +"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6: + version "2.3.7" + resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== dependencies: core-util-is "~1.0.0" inherits "~2.0.3" isarray "~1.0.0" - process-nextick-args "~1.0.6" + process-nextick-args "~2.0.0" safe-buffer "~5.1.1" - string_decoder "~1.0.3" + string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.2.6: - version "2.2.11" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" +readable-stream@1.1.x: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + integrity sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ== dependencies: core-util-is "~1.0.0" inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - safe-buffer "~5.0.1" - string_decoder "~1.0.0" - util-deprecate "~1.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" -readdirp@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" +readable-stream@^3.6.0: + version "3.6.0" + resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== dependencies: - graceful-fs "^4.1.2" - minimatch "^3.0.2" + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readdirp@^2.2.1: + version "2.2.1" + resolved "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz" + integrity sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ== + dependencies: + graceful-fs "^4.1.11" + micromatch "^3.1.10" readable-stream "^2.0.2" - set-immediate-shim "^1.0.1" -regex-cache@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" +readdirp@~3.5.0: + version "3.5.0" + resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz" + integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ== dependencies: - is-equal-shallow "^0.1.3" - is-primitive "^2.0.0" + picomatch "^2.2.1" -remove-trailing-separator@^1.0.1: +regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz#69b062d978727ad14dc6b56ba4ab772fd8d70511" + resolved "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +regexpp@^3.0.0, regexpp@^3.2.0: + version "3.2.0" + resolved "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz" + integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== + +regextras@^0.8.0: + version "0.8.0" + resolved "https://registry.npmjs.org/regextras/-/regextras-0.8.0.tgz" + integrity sha512-k519uI04Z3SaY0fLX843MRXnDeG2+vHOFsyhiPZvNLe7r8rD2YNRjq4BQLZZ0oAr2NrtvZlICsXysGNFPGa3CQ== + +release-zalgo@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz" + integrity "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA= sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==" + dependencies: + es6-error "^4.0.1" + +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz" + integrity "sha1-wkvOKig62tW8P1jg1IJJuSN52O8= sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==" repeat-element@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + version "1.1.4" + resolved "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.4.tgz" + integrity sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ== -repeat-string@^1.5.2: +repeat-string@^1.6.1: version "1.6.1" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" - -request@2.79.0: - version "2.79.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de" - dependencies: - aws-sign2 "~0.6.0" - aws4 "^1.2.1" - caseless "~0.11.0" - combined-stream "~1.0.5" - extend "~3.0.0" - forever-agent "~0.6.1" - form-data "~2.1.1" - har-validator "~2.0.6" - hawk "~3.1.3" - http-signature "~1.1.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.7" - oauth-sign "~0.8.1" - qs "~6.3.0" - stringstream "~0.0.4" - tough-cookie "~2.3.0" - tunnel-agent "~0.4.1" - uuid "^3.0.0" - -request@^2.73.0: - version "2.88.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.0" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.4.3" - tunnel-agent "^0.6.0" - uuid "^3.3.2" + resolved "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" + integrity "sha1-jcrkcOHIirwtYA//Sndihtp15jc= sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==" -request@^2.81.0: - version "2.81.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" - dependencies: - aws-sign2 "~0.6.0" - aws4 "^1.2.1" - caseless "~0.12.0" - combined-stream "~1.0.5" - extend "~3.0.0" - forever-agent "~0.6.1" - form-data "~2.1.1" - har-validator "~4.2.1" - hawk "~3.1.3" - http-signature "~1.1.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.7" - oauth-sign "~0.8.1" - performance-now "^0.2.0" - qs "~6.4.0" - safe-buffer "^5.0.1" - stringstream "~0.0.4" - tough-cookie "~2.3.0" - tunnel-agent "^0.6.0" - uuid "^3.0.0" - -request@^2.83.0: - version "2.83.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.6.0" - caseless "~0.12.0" - combined-stream "~1.0.5" - extend "~3.0.1" - forever-agent "~0.6.1" - form-data "~2.3.1" - har-validator "~5.0.3" - hawk "~6.0.2" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.17" - oauth-sign "~0.8.2" - performance-now "^2.1.0" - qs "~6.5.1" - safe-buffer "^5.1.1" - stringstream "~0.0.5" - tough-cookie "~2.3.3" - tunnel-agent "^0.6.0" - uuid "^3.1.0" +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" + integrity "sha1-jGStX9MNqxyXbiNE/+f3kqam30I= sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==" + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -requizzle@~0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.1.tgz#6943c3530c4d9a7e46f1cddd51c158fc670cdbde" +requizzle@^0.2.3: + version "0.2.3" + resolved "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz" + integrity sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ== dependencies: - underscore "~1.6.0" + lodash "^4.17.14" -resolve@1.1.x: - version "1.1.7" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" +resolve-from@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz" + integrity "sha1-six699nWiBvItuZTM17rywoYh0g= sha512-GnlH6vxLymXJNMBo7XP1fJIzBFbdYt49CuTwmB/6N53t+kMPRMFKz783LlQ4tv28XoQfMWinAJX6WCGf2IlaIw==" + +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz" + integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== + +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz" + integrity "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==" -resolve@~1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" +resolve@^1.10.0, resolve@^1.10.1, resolve@^1.11.1: + version "1.22.0" + resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz" + integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== dependencies: - path-parse "^1.0.5" + is-core-module "^2.8.1" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" -rest-facade@^1.10.1: - version "1.10.1" - resolved "https://registry.yarnpkg.com/rest-facade/-/rest-facade-1.10.1.tgz#a9b030ff50df28c9ea1a2719f94e369c47167d20" +rest-facade@^1.16.3: + version "1.16.3" + resolved "https://registry.npmjs.org/rest-facade/-/rest-facade-1.16.3.tgz" + integrity sha512-9BQTPLiwg23XZwcWi0ys1wTizfc//0b2G3U6vBWcgqh56ozs2K6CD+Jw4DYcw3AqdPQN7jj8nzRUcUXFVGzb0Q== dependencies: - bluebird "^2.10.2" change-case "^2.3.0" - deepmerge "^1.5.1" - superagent "^3.8.0" - superagent-proxy "^1.0.2" + deepmerge "^3.2.0" + lodash.get "^4.4.2" + superagent "^5.1.1" -retry@^0.10.1: - version "0.10.1" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4" +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== -right-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" +retry@^0.13.1: + version "0.13.1" + resolved "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz" + integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== + +rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3: + version "2.7.1" + resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== dependencies: - align-text "^0.1.1" + glob "^7.1.3" -rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== dependencies: - glob "^7.0.5" + glob "^7.1.3" -ripemd160@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-0.2.0.tgz#2bf198bde167cacfa51c0a928e84b68bbe171fce" +ripemd160@^2.0.0, ripemd160@^2.0.1: + version "2.0.2" + resolved "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz" + integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" -safe-buffer@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.0.tgz#fe4c8460397f9eaaaa58e73be46273408a45e223" +run-node@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz" + integrity sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A== -safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" +run-queue@^1.0.0, run-queue@^1.0.3: + version "1.0.3" + resolved "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz" + integrity "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec= sha512-ntymy489o0/QQplUDnpYAYUsO50K9SBrIVaKCWDOJzYJts0f9WH9RFJkyagebkw5+y1oi00R7ynNW/d12GBumg==" + dependencies: + aproba "^1.1.1" -safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@~5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz" + integrity "sha1-QKNmnzsHfR6UPURinhV91IAjvy4= sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==" + dependencies: + ret "~0.1.10" -samsam@1.1.2, samsam@~1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" +"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -semver@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" +schema-utils@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz" + integrity sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g== + dependencies: + ajv "^6.1.0" + ajv-errors "^1.0.0" + ajv-keywords "^3.1.0" -semver@~5.0.1: - version "5.0.3" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a" +semver-compare@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz" + integrity "sha1-De4hahyUGrN+nvsXiPavxf9VN/w= sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==" + +"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0: + version "5.7.1" + resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + +semver@^6.0.0, semver@^6.1.0: + version "6.3.0" + resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + +semver@^7.3.2, semver@^7.3.5: + version "7.3.7" + resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz" + integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== + dependencies: + lru-cache "^6.0.0" + +semver@^7.3.8: + version "7.3.8" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" + integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== + dependencies: + lru-cache "^6.0.0" sentence-case@^1.1.1, sentence-case@^1.1.2: version "1.1.3" - resolved "https://registry.yarnpkg.com/sentence-case/-/sentence-case-1.1.3.tgz#8034aafc2145772d3abe1509aa42c9e1042dc139" + resolved "https://registry.npmjs.org/sentence-case/-/sentence-case-1.1.3.tgz" + integrity "sha1-gDSq/CFFdy06vhUJqkLJ4QQtwTk= sha512-laa/UDTPXsrQnoN/Kc8ZO7gTeEjMsuPiDgUCk9N0iINRZvqAMCTXjGl8+tD27op1eF/JHbdUlEUmovDh6AX7sA==" dependencies: lower-case "^1.1.1" -set-blocking@~2.0.0: +serialize-javascript@5.0.1: + version "5.0.1" + resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz" + integrity sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA== + dependencies: + randombytes "^2.1.0" + +serialize-javascript@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz" + integrity sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw== + dependencies: + randombytes "^2.1.0" + +set-blocking@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + resolved "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz" + integrity "sha1-BF+XgtARrppoA93TgrJDkrPYkPc= sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" -set-immediate-shim@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" +set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" setimmediate@^1.0.4: version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + resolved "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz" + integrity "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" -setprototypeof@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== -sha.js@2.2.6: - version "2.2.6" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.2.6.tgz#17ddeddc5f722fb66501658895461977867315ba" +sha.js@^2.4.0, sha.js@^2.4.8: + version "2.4.11" + resolved "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz" + integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" shebang-command@^1.2.0: version "1.2.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz" + integrity "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==" dependencies: shebang-regex "^1.0.0" +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + shebang-regex@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - -sigmund@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" + resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz" + integrity "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==" -signal-exit@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -sinon@^1.17.1: - version "1.17.7" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf" - dependencies: - formatio "1.1.1" - lolex "1.3.2" - samsam "1.1.2" - util ">=0.10.3 <1" +side-channel@^1.0.4: + version "1.0.4" + resolved "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz" + integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== + dependencies: + call-bind "^1.0.0" + get-intrinsic "^1.0.2" + object-inspect "^1.9.0" + +signal-exit@^3.0.0, signal-exit@^3.0.2: + version "3.0.7" + resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +sinon@^14.0.0: + version "14.0.0" + resolved "https://registry.npmjs.org/sinon/-/sinon-14.0.0.tgz" + integrity sha512-ugA6BFmE+WrJdh0owRZHToLd32Uw3Lxq6E6LtNRU+xTVBefx632h03Q7apXWRsRdZAJ41LB8aUfn2+O4jsDNMw== + dependencies: + "@sinonjs/commons" "^1.8.3" + "@sinonjs/fake-timers" "^9.1.2" + "@sinonjs/samsam" "^6.1.1" + diff "^5.0.0" + nise "^5.1.1" + supports-color "^7.2.0" + +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -smart-buffer@^1.0.13: - version "1.1.15" - resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-1.1.15.tgz#7f114b5b65fab3e2a35aa775bb12f0d1c649bf16" +smart-buffer@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" + integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== snake-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-1.1.2.tgz#0c2f25e305158d9a18d3d977066187fef8a5a66a" + resolved "https://registry.npmjs.org/snake-case/-/snake-case-1.1.2.tgz" + integrity "sha1-DC8l4wUVjZoY09l3BmGH/vilpmo= sha512-oapUKC+qulnUIN+/O7Tbl2msi9PQvJeivGN9RNbygxzI2EOY0gA96i8BJLYnGUWSLGcYtyW4YYqnGTZEySU/gg==" dependencies: sentence-case "^1.1.2" -sntp@1.x.x: - version "1.0.9" - resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== dependencies: - hoek "2.x.x" + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" -sntp@2.x.x: - version "2.0.2" - resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.0.2.tgz#5064110f0af85f7cfdb7d6b67a40028ce52b4b2b" +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== dependencies: - hoek "4.x.x" + kind-of "^3.2.0" -socks-proxy-agent@2: - version "2.1.1" - resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-2.1.1.tgz#86ebb07193258637870e13b7bd99f26c663df3d3" +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz" + integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== dependencies: - agent-base "2" - extend "3" - socks "~1.1.5" - -socks-proxy-agent@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-3.0.1.tgz#2eae7cf8e2a82d34565761539a7f9718c5617659" + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +socks-proxy-agent@5, socks-proxy-agent@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz#032fb583048a29ebffec2e6a73fca0761f48177e" + integrity sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ== dependencies: - agent-base "^4.1.0" - socks "^1.1.10" + agent-base "^6.0.2" + debug "4" + socks "^2.3.3" -socks@^1.1.10, socks@~1.1.5: - version "1.1.10" - resolved "https://registry.yarnpkg.com/socks/-/socks-1.1.10.tgz#5b8b7fc7c8f341c53ed056e929b7bf4de8ba7b5a" +socks@^2.3.3: + version "2.7.1" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.7.1.tgz#d8e651247178fde79c0663043e07240196857d55" + integrity sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ== dependencies: - ip "^1.1.4" - smart-buffer "^1.0.13" + ip "^2.0.0" + smart-buffer "^4.2.0" -source-list-map@~0.1.7: - version "0.1.8" - resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-0.1.8.tgz#c550b2ab5427f6b3f21f5afead88c4f5587b2106" +source-list-map@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz" + integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== + +source-map-resolve@^0.5.0: + version "0.5.3" + resolved "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz" + integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-support@~0.5.12: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map-url@^0.4.0: + version "0.4.1" + resolved "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz" + integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw== + +source-map@^0.5.6: + version "0.5.7" + resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz" + integrity "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==" -source-map@^0.4.4, source-map@~0.4.1: - version "0.4.4" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" - dependencies: - amdefine ">=0.0.4" +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== source-map@~0.1.38: version "0.1.43" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" + resolved "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz" + integrity "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y= sha512-VtCvB9SIQhk3aF6h+N85EaqIaBFIAfZ9Cu+NJHHVvc8BbEcnvDcFw6sqQ2dQrT6SlOrZq3tIvyD9+EGq/lJryQ==" dependencies: amdefine ">=0.0.4" -source-map@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d" +spawn-wrap@^1.4.2: + version "1.4.3" + resolved "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-1.4.3.tgz" + integrity sha512-IgB8md0QW/+tWqcavuFgKYR/qIRvJkRLPJDFaoXtLLUaVcCDK0+HeFTkmQHj3eprcYhc+gOl0aEA1w7qZlYezw== dependencies: - amdefine ">=0.0.4" + foreground-child "^1.5.6" + mkdirp "^0.5.0" + os-homedir "^1.0.1" + rimraf "^2.6.2" + signal-exit "^3.0.2" + which "^1.3.0" -source-map@~0.5.1: - version "0.5.6" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" +spdx-correct@^3.0.0: + version "3.1.1" + resolved "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz" + integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" -source-map@~0.5.6: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" +spdx-exceptions@^2.1.0: + version "2.3.0" + resolved "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== + +spdx-expression-parse@^3.0.0, spdx-expression-parse@^3.0.1: + version "3.0.1" + resolved "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.11" + resolved "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz" + integrity sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g== + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== + dependencies: + extend-shallow "^3.0.0" sprintf-js@~1.0.2: version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" + integrity "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" -sshpk@^1.7.0: - version "1.13.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" +ssri@^6.0.1: + version "6.0.2" + resolved "https://registry.npmjs.org/ssri/-/ssri-6.0.2.tgz" + integrity sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q== dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - dashdash "^1.12.0" - getpass "^0.1.1" - optionalDependencies: - bcrypt-pbkdf "^1.0.0" - ecc-jsbn "~0.1.1" - jsbn "~0.1.0" - tweetnacl "~0.14.0" + figgy-pudding "^3.5.1" -"statuses@>= 1.3.1 < 2": - version "1.4.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz" + integrity "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==" + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" -stream-browserify@^2.0.1: +statuses@2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== + +stream-browserify@^2.0.1: + version "2.0.2" + resolved "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz" + integrity sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg== dependencies: inherits "~2.0.1" readable-stream "^2.0.2" -stream-http@^2.3.1: - version "2.7.2" - resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.7.2.tgz#40a050ec8dc3b53b33d9909415c02c0bf1abfbad" +stream-each@^1.1.0: + version "1.2.3" + resolved "https://registry.npmjs.org/stream-each/-/stream-each-1.2.3.tgz" + integrity sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw== + dependencies: + end-of-stream "^1.1.0" + stream-shift "^1.0.0" + +stream-http@^2.7.2: + version "2.8.3" + resolved "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz" + integrity sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw== dependencies: builtin-status-codes "^3.0.0" inherits "^2.0.1" - readable-stream "^2.2.6" + readable-stream "^2.3.6" to-arraybuffer "^1.0.0" xtend "^4.0.0" -string-replace-webpack-plugin@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/string-replace-webpack-plugin/-/string-replace-webpack-plugin-0.0.3.tgz#82c67448cea95ec002a1bfcfd2fb0195cd12bd24" +stream-shift@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz" + integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== + +string-replace-webpack-plugin@0.1.3: + version "0.1.3" + resolved "https://registry.npmjs.org/string-replace-webpack-plugin/-/string-replace-webpack-plugin-0.1.3.tgz" + integrity "sha1-c8ZX51nWbP6Arh4M8JGqJW0OcVw= sha512-uKyQi7AKVVMT7vLSA6qMAY5Pm4Ib13iBb9qAlIiCp44jxAQMlbX+4W9A050d4aLzf0siXdB8Xw1yODJNh2Z45w==" dependencies: async "~0.2.10" + loader-utils "~0.2.3" + optionalDependencies: css-loader "^0.9.1" file-loader "^0.8.1" - loader-utils "~0.2.3" style-loader "^0.8.3" -string-width@^1.0.1, string-width@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" +"string-width@^1.0.2 || 2": + version "2.1.1" + resolved "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" -string_decoder@^0.10.25, string_decoder@~0.10.x: - version "0.10.31" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" -string_decoder@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179" +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: - safe-buffer "~5.0.1" + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" -string_decoder@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" +string_decoder@^1.0.0, string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== dependencies: safe-buffer "~5.1.0" -stringstream@~0.0.4, stringstream@~0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + integrity sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ== + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz" + integrity "sha1-qEeQIusaw2iocTibY1JixQXuNo8= sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==" + dependencies: + ansi-regex "^3.0.0" + +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - ansi-regex "^2.0.0" + ansi-regex "^5.0.1" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz" + integrity "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==" strip-eof@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - -strip-indent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" + resolved "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz" + integrity "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==" -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" +strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== style-loader@^0.8.3: version "0.8.3" - resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.8.3.tgz#f4f92eb7db63768748f15065cd6700f5a1c85357" + resolved "https://registry.npmjs.org/style-loader/-/style-loader-0.8.3.tgz" + integrity "sha1-9Pkut9tjdodI8VBlzWcA9aHIU1c= sha512-ICp1ISTuh4+aunEXH1XjCBEtPWcX6PKJ5D0f3g8/+mPHEUbcwo9ynMUUWKSH26DItIIlB/PStP5TTaQF+V7y7Q==" dependencies: loader-utils "^0.2.5" -superagent-proxy@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/superagent-proxy/-/superagent-proxy-1.0.2.tgz#92d3660578f618ed43a82cf8cac799fe2938ba2d" - dependencies: - debug "2" - proxy-agent "2" - -superagent@^3.8.0: - version "3.8.2" - resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.2.tgz#e4a11b9d047f7d3efeb3bbe536d9ec0021d16403" - dependencies: - component-emitter "^1.2.0" - cookiejar "^2.1.0" - debug "^3.1.0" - extend "^3.0.0" - form-data "^2.3.1" - formidable "^1.1.1" - methods "^1.1.1" - mime "^1.4.1" - qs "^6.5.1" - readable-stream "^2.0.5" - -supports-color@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-1.2.0.tgz#ff1ed1e61169d06b3cf2d588e188b18d8847e17e" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" +superagent-proxy@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/superagent-proxy/-/superagent-proxy-3.0.0.tgz#e1a17ccba25883599e18d2974020fe83ee7d95d1" + integrity sha512-wAlRInOeDFyd9pyonrkJspdRAxdLrcsZ6aSnS+8+nu4x1aXbz6FWSTT9M6Ibze+eG60szlL7JA8wEIV7bPWuyQ== + dependencies: + debug "^4.3.2" + proxy-agent "^5.0.0" + +superagent@^5.1.1: + version "5.3.1" + resolved "https://registry.npmjs.org/superagent/-/superagent-5.3.1.tgz" + integrity sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ== + dependencies: + component-emitter "^1.3.0" + cookiejar "^2.1.2" + debug "^4.1.1" + fast-safe-stringify "^2.0.7" + form-data "^3.0.0" + formidable "^1.2.2" + methods "^1.1.2" + mime "^2.4.6" + qs "^6.9.4" + readable-stream "^3.6.0" + semver "^7.3.2" + +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" -supports-color@^3.1.0: - version "3.2.3" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== dependencies: - has-flag "^1.0.0" + has-flag "^3.0.0" -supports-color@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0" +supports-color@^6.1.0: + version "6.1.0" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz" + integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== dependencies: has-flag "^3.0.0" +supports-color@^7.1.0, supports-color@^7.2.0: + version "7.2.0" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + swap-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/swap-case/-/swap-case-1.1.2.tgz#c39203a4587385fad3c850a0bd1bcafa081974e3" + resolved "https://registry.npmjs.org/swap-case/-/swap-case-1.1.2.tgz" + integrity "sha1-w5IDpFhzhfrTyFCgvRvK+ggZdOM= sha512-BAmWG6/bx8syfc6qXPprof3Mn5vQgf5dwdUNJhsNqU9WdPt5P+ES/wQ5bxfijy8zwZgZZHslC3iAsxsuQMCzJQ==" dependencies: lower-case "^1.1.1" upper-case "^1.1.1" taffydb@2.6.2: version "2.6.2" - resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268" + resolved "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz" + integrity "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg= sha512-y3JaeRSplks6NYQuCOj3ZFMO3j60rTwbuKCvZxsAraGYH2epusatvZ0baZYA01WsGqJBq/Dl6vOrMUJqyMj8kA==" -tapable@^0.1.8, tapable@~0.1.8: - version "0.1.10" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.1.10.tgz#29c35707c2b70e50d07482b5d202e8ed446dafd4" - -tar-pack@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984" - dependencies: - debug "^2.2.0" - fstream "^1.0.10" - fstream-ignore "^1.0.5" - once "^1.3.3" - readable-stream "^2.1.4" - rimraf "^2.5.1" - tar "^2.2.1" - uid-number "^0.0.6" - -tar@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" +tapable@^1.0.0, tapable@^1.1.3: + version "1.1.3" + resolved "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz" + integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== + +terser-webpack-plugin@^1.4.3: + version "1.4.5" + resolved "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.5.tgz" + integrity sha512-04Rfe496lN8EYruwi6oPQkG0vo8C+HT49X687FZnpPF0qMAIHONI6HEXYPKDOE8e5HjXTyKfqRd/agHtH0kOtw== + dependencies: + cacache "^12.0.2" + find-cache-dir "^2.1.0" + is-wsl "^1.1.0" + schema-utils "^1.0.0" + serialize-javascript "^4.0.0" + source-map "^0.6.1" + terser "^4.1.2" + webpack-sources "^1.4.0" + worker-farm "^1.7.0" + +terser@^4.1.2: + version "4.8.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.1.tgz#a00e5634562de2239fd404c649051bf6fc21144f" + integrity sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw== + dependencies: + commander "^2.20.0" + source-map "~0.6.1" + source-map-support "~0.5.12" + +test-exclude@^5.2.3: + version "5.2.3" + resolved "https://registry.npmjs.org/test-exclude/-/test-exclude-5.2.3.tgz" + integrity sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g== dependencies: - block-stream "*" - fstream "^1.0.2" - inherits "2" + glob "^7.1.3" + minimatch "^3.0.4" + read-pkg-up "^4.0.0" + require-main-filename "^2.0.0" -thunkify@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/thunkify/-/thunkify-2.1.2.tgz#faa0e9d230c51acc95ca13a361ac05ca7e04553d" +text-table@^0.2.0: + version "0.2.0" + resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz" + integrity "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==" -timers-browserify@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.2.tgz#ab4883cf597dcd50af211349a00fbca56ac86b86" +through2@^2.0.0: + version "2.0.5" + resolved "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz" + integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== + dependencies: + readable-stream "~2.3.6" + xtend "~4.0.1" + +timers-browserify@^2.0.4: + version "2.0.12" + resolved "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.12.tgz" + integrity sha512-9phl76Cqm6FhSX9Xe1ZUAMLtm1BLkKj2Qd5ApyWkXzsMRaA7dgr81kf4wJmQf/hAvg8EEyJxDo3du/0KlhPiKQ== dependencies: setimmediate "^1.0.4" title-case@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/title-case/-/title-case-1.1.2.tgz#fae4a6ae546bfa22d083a0eea910a40d12ed4f5a" + resolved "https://registry.npmjs.org/title-case/-/title-case-1.1.2.tgz" + integrity "sha1-+uSmrlRr+iLQg6DuqRCkDRLtT1o= sha512-xYbo5Um5MBgn24xJSK+x5hZ8ehuGXTVhgx32KJCThHRHwpyIb1lmABi1DH5VvN9E7rNEquPjz//rF/tZQd7mjQ==" dependencies: sentence-case "^1.1.1" upper-case "^1.0.3" to-arraybuffer@^1.0.0: version "1.0.1" - resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" + resolved "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz" + integrity "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M= sha512-okFlQcoGTi4LQBG/PgSYblw9VOyptsz2KJZqc6qtgGdes8VktzUQkj4BI2blit072iS8VODNcMA+tvnS9dnuMA==" -to-iso-string@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" +to-fast-properties@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz" + integrity "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==" -tough-cookie@~2.3.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz" + integrity "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==" + dependencies: + kind-of "^3.0.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz" + integrity "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==" dependencies: - punycode "^1.4.1" + is-number "^3.0.0" + repeat-string "^1.6.1" -tough-cookie@~2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== dependencies: - punycode "^1.4.1" + is-number "^7.0.0" -tough-cookie@~2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== dependencies: - psl "^1.1.24" - punycode "^1.4.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + +tslib@^2.0.1: + version "2.4.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" + integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== tty-browserify@0.0.0: version "0.0.0" - resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" + resolved "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz" + integrity "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY= sha512-JVa5ijo+j/sOoHGjw0sxw734b1LhBkQ3bvUGNdxnVXDCX81Yx7TFgnZygxrIIWn23hbfTaMYLwRmAxFyDuFmIw==" -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== dependencies: - safe-buffer "^5.0.1" - -tunnel-agent@~0.4.1: - version "0.4.3" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + prelude-ls "^1.2.1" type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + integrity sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg== dependencies: prelude-ls "~1.1.2" -type-detect@0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" +type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.5, type-detect@^4.0.8: + version "4.0.8" + resolved "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -uglify-js@^2.6, uglify-js@~2.7.3: - version "2.7.5" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.7.5.tgz#4612c0c7baaee2ba7c487de4904ae122079f2ca8" - dependencies: - async "~0.2.6" - source-map "~0.5.1" - uglify-to-browserify "~1.0.0" - yargs "~3.10.0" +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== -uglify-to-browserify@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" +type-fest@^0.6.0: + version "0.6.0" + resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz" + integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg== -uid-number@^0.0.6: +typedarray@^0.0.6: version "0.0.6" - resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" + integrity "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" -underscore-contrib@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/underscore-contrib/-/underscore-contrib-0.3.0.tgz#665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7" +uc.micro@^1.0.1, uc.micro@^1.0.5: + version "1.0.6" + resolved "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz" + integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== + +underscore@~1.13.2: + version "1.13.3" + resolved "https://registry.npmjs.org/underscore/-/underscore-1.13.3.tgz" + integrity sha512-QvjkYpiD+dJJraRA8+dGAU4i7aBbb2s0S3jA45TFOvg2VgqvdCDd/3N6CqA8gluk1W91GLoXg5enMUx560QzuA== + +union-value@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz" + integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg== dependencies: - underscore "1.6.0" + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^2.0.1" -underscore@1.6.0, underscore@~1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8" +unique-filename@^1.1.1: + version "1.1.1" + resolved "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz" + integrity sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ== + dependencies: + unique-slug "^2.0.0" -underscore@~1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" +unique-slug@^2.0.0: + version "2.0.2" + resolved "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.2.tgz" + integrity sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w== + dependencies: + imurmurhash "^0.1.4" + +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== unpipe@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz" + integrity "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==" + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +upath@^1.1.1: + version "1.2.0" + resolved "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz" + integrity sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg== upper-case-first@^1.1.0: version "1.1.2" - resolved "https://registry.yarnpkg.com/upper-case-first/-/upper-case-first-1.1.2.tgz#5d79bedcff14419518fd2edb0a0507c9b6859115" + resolved "https://registry.npmjs.org/upper-case-first/-/upper-case-first-1.1.2.tgz" + integrity "sha1-XXm+3P8UQZUY/S7bCgUHybaFkRU= sha512-wINKYvI3Db8dtjikdAqoBbZoP6Q+PZUyfMR7pmwHzjC2quzSkUq5DmPrTtPEqHaz8AGtmsB4TqwapMTM1QAQOQ==" dependencies: upper-case "^1.1.1" upper-case@^1.0.3, upper-case@^1.1.0, upper-case@^1.1.1: version "1.1.3" - resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-1.1.3.tgz#f6b4501c2ec4cdd26ba78be7222961de77621598" + resolved "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz" + integrity "sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg= sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==" + +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz" + integrity "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==" url@^0.11.0: version "0.11.0" - resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + resolved "https://registry.npmjs.org/url/-/url-0.11.0.tgz" + integrity "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE= sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==" dependencies: punycode "1.3.2" querystring "0.2.0" -urlgrey@0.4.4: - version "0.4.4" - resolved "https://registry.yarnpkg.com/urlgrey/-/urlgrey-0.4.4.tgz#892fe95960805e85519f1cd4389f2cb4cbb7652f" +use@^3.1.0: + version "3.1.1" + resolved "https://registry.npmjs.org/use/-/use-3.1.1.tgz" + integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== -util-deprecate@~1.0.1: +util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + integrity "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" -util@0.10.3, "util@>=0.10.3 <1", util@^0.10.3: +util@0.10.3: version "0.10.3" - resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + resolved "https://registry.npmjs.org/util/-/util-0.10.3.tgz" + integrity "sha1-evsa/lCAUkZInj23/g7TeTNqwPk= sha512-5KiHfsmkqacuKjkRkdV7SsfDJ2EGiPsK92s2MhNSY0craxjTdKTtqKsJaCWp4LW33ZZ0OPUv1WO/TFvNQRiQxQ==" dependencies: inherits "2.0.1" -uuid@^3.0.0, uuid@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" +util@^0.11.0: + version "0.11.1" + resolved "https://registry.npmjs.org/util/-/util-0.11.1.tgz" + integrity sha512-HShAsny+zS2TZfaXxD9tYj4HQGlBezXZMZuM/S5PKLLoZkShZiGk9o5CzukI1LVHZvjdvZ2Sj1aW/Ndn2NB/HQ== + dependencies: + inherits "2.0.3" uuid@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + version "3.4.0" + resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" + integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== + +v8-compile-cache@^2.0.3: + version "2.3.0" + resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz" + integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== -verror@1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== dependencies: - extsprintf "1.0.2" + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" -very-fast-args@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/very-fast-args/-/very-fast-args-1.1.0.tgz#e16d1d1faf8a6e596a246421fd90a77963d0b396" +vm-browserify@^1.0.1: + version "1.1.2" + resolved "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz" + integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== -vm-browserify@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73" +vm2@^3.9.8: + version "3.9.11" + resolved "https://registry.yarnpkg.com/vm2/-/vm2-3.9.11.tgz#a880f510a606481719ec3f9803b940c5805a06fe" + integrity sha512-PFG8iJRSjvvBdisowQ7iVF580DXb1uCIiGaXgm7tynMR1uTBlv7UJlB1zdv5KJ+Tmq1f0Upnj3fayoEOPpCBKg== dependencies: - indexof "0.0.1" + acorn "^8.7.0" + acorn-walk "^8.2.0" -watchpack@^0.2.1: - version "0.2.9" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-0.2.9.tgz#62eaa4ab5e5ba35fdfc018275626e3c0f5e3fb0b" +watchpack-chokidar2@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/watchpack-chokidar2/-/watchpack-chokidar2-2.0.1.tgz" + integrity sha512-nCFfBIPKr5Sh61s4LPpy1Wtfi0HE8isJ3d2Yb5/Ppw2P2B/3eVSEBjKfN0fmHJSK14+31KwMKmcrzs2GM4P0Ww== dependencies: - async "^0.9.0" - chokidar "^1.0.0" - graceful-fs "^4.1.2" + chokidar "^2.1.8" -webpack-core@~0.6.9: - version "0.6.9" - resolved "https://registry.yarnpkg.com/webpack-core/-/webpack-core-0.6.9.tgz#fc571588c8558da77be9efb6debdc5a3b172bdc2" - dependencies: - source-list-map "~0.1.7" - source-map "~0.4.1" - -webpack@^1.12.14: - version "1.15.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.15.0.tgz#4ff31f53db03339e55164a9d468ee0324968fe98" - dependencies: - acorn "^3.0.0" - async "^1.3.0" - clone "^1.0.2" - enhanced-resolve "~0.9.0" - interpret "^0.6.4" - loader-utils "^0.2.11" - memory-fs "~0.3.0" - mkdirp "~0.5.0" - node-libs-browser "^0.7.0" - optimist "~0.6.0" - supports-color "^3.1.0" - tapable "~0.1.8" - uglify-js "~2.7.3" - watchpack "^0.2.1" - webpack-core "~0.6.9" - -which@^1.1.1: - version "1.2.14" - resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" +watchpack@^1.7.4: + version "1.7.5" + resolved "https://registry.npmjs.org/watchpack/-/watchpack-1.7.5.tgz" + integrity sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ== dependencies: - isexe "^2.0.0" + graceful-fs "^4.1.2" + neo-async "^2.5.0" + optionalDependencies: + chokidar "^3.4.1" + watchpack-chokidar2 "^2.0.1" + +webpack-sources@^1.4.0, webpack-sources@^1.4.1: + version "1.4.3" + resolved "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz" + integrity sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ== + dependencies: + source-list-map "^2.0.0" + source-map "~0.6.1" + +webpack@^4.36.1: + version "4.46.0" + resolved "https://registry.npmjs.org/webpack/-/webpack-4.46.0.tgz" + integrity sha512-6jJuJjg8znb/xRItk7bkT0+Q7AHCYjjFnvKIWQPkNIOyRqoCGvkOs0ipeQzrqz4l5FtN5ZI/ukEHroeX/o1/5Q== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-module-context" "1.9.0" + "@webassemblyjs/wasm-edit" "1.9.0" + "@webassemblyjs/wasm-parser" "1.9.0" + acorn "^6.4.1" + ajv "^6.10.2" + ajv-keywords "^3.4.1" + chrome-trace-event "^1.0.2" + enhanced-resolve "^4.5.0" + eslint-scope "^4.0.3" + json-parse-better-errors "^1.0.2" + loader-runner "^2.4.0" + loader-utils "^1.2.3" + memory-fs "^0.4.1" + micromatch "^3.1.10" + mkdirp "^0.5.3" + neo-async "^2.6.1" + node-libs-browser "^2.2.1" + schema-utils "^1.0.0" + tapable "^1.1.3" + terser-webpack-plugin "^1.4.3" + watchpack "^1.7.4" + webpack-sources "^1.4.1" + +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz" + integrity "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==" -which@^1.2.9: - version "1.3.0" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" +which@2.0.2, which@^2.0.1: + version "2.0.2" + resolved "https://registry.npmjs.org/which/-/which-2.0.2.tgz" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== dependencies: isexe "^2.0.0" -which@^1.3.1: +which@^1.2.9, which@^1.3.0: version "1.3.1" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + resolved "https://registry.npmjs.org/which/-/which-1.3.1.tgz" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== dependencies: isexe "^2.0.0" -wide-align@^1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" +wide-align@1.1.3: + version "1.1.3" + resolved "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz" + integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== dependencies: - string-width "^1.0.2" + string-width "^1.0.2 || 2" -window-size@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" +word-wrap@^1.2.3, word-wrap@~1.2.3: + version "1.2.3" + resolved "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz" + integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== -wordwrap@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" +worker-farm@^1.7.0: + version "1.7.0" + resolved "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz" + integrity sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw== + dependencies: + errno "~0.1.7" -wordwrap@^1.0.0, wordwrap@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" +workerpool@6.1.0: + version "6.1.0" + resolved "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz" + integrity sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg== -wordwrap@~0.0.2: - version "0.0.3" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" wrappy@1: version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" + integrity "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + +write-file-atomic@^2.4.2: + version "2.4.3" + resolved "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz" + integrity sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ== + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" xml@^1.0.0: version "1.0.1" - resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + resolved "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz" + integrity "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==" -xmlcreate@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f" +xmlcreate@^2.0.4: + version "2.0.4" + resolved "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz" + integrity sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg== xregexp@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943" + integrity sha512-xl/50/Cf32VsGq/1R8jJE5ajH1yMCQkpmoS10QbFZWl2Oor4H0Me64Pu2yxvsRWK3m6soJbmGfzSR7BYmDcWAA== -xtend@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" +xtend@^4.0.0, xtend@~4.0.1: + version "4.0.2" + resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + +y18n@^4.0.0: + version "4.0.3" + resolved "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz" + integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== -yallist@^2.0.0, yallist@^2.1.2: +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yallist@^2.0.0: version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + resolved "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz" + integrity "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==" + +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yargs@~3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" +yargs-parser@20.2.4, yargs-parser@^20.2.2: + version "20.2.4" + resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^13.0.0, yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== dependencies: - camelcase "^1.0.2" - cliui "^2.1.0" - decamelize "^1.0.0" - window-size "0.1.0" + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0: + version "16.2.0" + resolved "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yargs@^13.2.2: + version "13.3.2" + resolved "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.2" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==