1.2.2 • Published 2 years ago

@cyrusbio/auth0-authorization v1.2.2

Weekly downloads
1
License
-
Repository
github
Last release
2 years ago

auth0-authorization

Auth0 Authorization Extension API client library

Installation

  npm install @cyrusbio/auth0-authorization

AuthorizationClient

Use this client to access the Auth0 Authorization Extension API.

import { AuthorizationClient } from '@cyrusbio/auth0-authorization';

const authorization = new AuthorizationClient({
  clientId: `${CLIENT_ID}`,
  clientSecret: `${CLIENT_SECRET}`,
  domain: `${TENANT}.auth0.com`,
  extensionUrl: `https://${TENANT}.us.webtask.io/xxx/api`,
});

Behind the scenes the client obtains an access token, caches it, and automatically refreshes it if it expires.

Each method returns a promise.

const groups = await authorization.getGroups();

Types

TypeScript types are included.

import { IAuth0AuthorizationApiGroup } from '@cyrusbio/auth0-authorization';

let group: IAuth0AuthorizationApiGroup;

Testing

All tests run against a live Auth0 tenant instance.

Configuration

First you need to set up a .env file containing the Auth0 configuration. Here is an example .env that includes all non-secret values (cyrusbio-identity-lib is an Auth0 tenant made specifically for testing this library):

cat <<'EOF' > .env
AUTH0_DOMAIN=xxx
AUTH0_CLIENT_ID=xxx
AUTH0_CLIENT_SECRET=xxx
AUTH0_EXTENSION_URL=xxx
EOF

Run all tests

env $(cat .env | xargs) npm test

Run individual test

npm run testbuild
env $(cat .env | xargs) node_modules/.bin/ava test/[test-name].spec.js

Logging in tests

Logging in tests should use ava t.log instead of console.log. Those logs will appear only when running ava in verbose mode:

env $(cat .env | xargs) node_modules/.bin/ava test/[test-name].spec.js --verbose
1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

3 years ago

1.1.6-dev-5

3 years ago

1.1.6-dev-7

3 years ago

1.1.6-dev-1

3 years ago

1.1.6-dev-2

3 years ago

1.1.6-dev-3

3 years ago

1.1.6-dev-4

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.6-dev

3 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago