auth0-sso-login
Version:
A Library to simplify the auth0 sso login process
56 lines (45 loc) • 1.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _auth0Js = require("auth0-js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Auth0ClientProvider = /*#__PURE__*/function () {
/**
* @constructor the auth0Manager
* @param {Object} config
*/
function Auth0ClientProvider(config) {
_classCallCheck(this, Auth0ClientProvider);
this.config = config;
this.webAuth = null;
this.managementClient = null;
}
/**
* @description Get the Auth0 client
* @return {*|void}
*/
_createClass(Auth0ClientProvider, [{
key: "getClient",
value: function getClient() {
return this.webAuth || (this.webAuth = new _auth0Js.WebAuth({
domain: this.config.domain,
clientID: this.config.clientId,
scope: 'openid profile email'
}));
}
}, {
key: "getManagementClient",
value: function getManagementClient(auth0AccessToken) {
return this.managementClient || (this.managementClient = new _auth0Js.Management({
domain: this.config.domain,
token: auth0AccessToken
}));
}
}]);
return Auth0ClientProvider;
}();
exports["default"] = Auth0ClientProvider;