Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/another-guy/promisify-auth0
Auth0-js wrapper with Promise based interface
https://github.com/another-guy/promisify-auth0
auth0 authentication authorization browser brucke javascript jwt login oauth2 promise promisify sdk wrapper
Last synced: 10 days ago
JSON representation
Auth0-js wrapper with Promise based interface
- Host: GitHub
- URL: https://github.com/another-guy/promisify-auth0
- Owner: another-guy
- License: mit
- Created: 2017-10-02T18:47:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-29T19:16:32.000Z (over 6 years ago)
- Last Synced: 2024-10-13T04:11:53.098Z (25 days ago)
- Topics: auth0, authentication, authorization, browser, brucke, javascript, jwt, login, oauth2, promise, promisify, sdk, wrapper
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/promisify-auth0
- Size: 55.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# promisify-auth0-js
Promisifying wrapper around the Client Side Javascript toolkit for Auth0 API
[![Known Vulnerabilities](https://snyk.io/test/npm/promisify-auth0/badge.svg)](https://snyk.io/test/npm/promisify-auth0)
## Install
From [npm](https://www.npmjs.com/package/promisify-auth0)
```
npm i --save promisify-auth0
```## Basic Usage
The package is mirroring the original [auth0.js](https://github.com/auth0/auth0.js) API. The only difference is that instead of NodeJS callback function style, `promisify-auth0` allows you to get `Promise` instead which help avoid callback hell and play nicely with `async/await`.
You will still need to create an original Auth0 objects and inject them into the corresponding wrapping types, something like this:
```ts
import { Authentication as NativeAuthentication } from 'auth0-js';
import { Authentication } from 'promisify-auth0';const nativeAuthentication: NativeAuthentication = ...;
const authentication = new Authentication(nativeAuthentication);const options = { realm: '...', audience: '...', username: '...', password: '...', scope: '...' };
authentication.login(options)
.then(loginResult => {
// ...
})
.catch(caughtError => {
// ...
});
```The last piece of code could be rewritten in a more imperative style while maintaining the asyncronous execution model.
```ts
try {
const loginResult = await authentication.login(options);
// ...
} catch (caughtError) {
// ...
}
```## License and other
This code is distributed under [MIT license](https://github.com/another-guy/promisify-auth0/blob/master/LICENSE).
Please respect the [Code of Conduct](https://github.com/another-guy/promisify-auth0/blob/master/CODE_OF_CONDUCT.md).
Feel free to [contribute](https://github.com/another-guy/promisify-auth0/blob/master/CONTRIBUTING.md).