Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Inject, Service } from 'typedi'
import { Authentication, Management } from 'auth0-js'
import {
AUTH0_CERT,
AUTH0_MANAGEMENT_CLIENT_CONFIG,
Auth0Cert,
Auth0Config
} from '../rest-api'
import { Observable, Observer, of } from 'rxjs'
import { flatMap, map } from 'rxjs/operators'
import { verify } from 'jsonwebtoken'
@Service()
export class UserService {
private readonly client = new Authentication(this.config)
// tslint:disable-next-line:readonly-keyword
private token: string
constructor(
@Inject(type => AUTH0_MANAGEMENT_CLIENT_CONFIG)
private config: Auth0Config,
@Inject(type => AUTH0_CERT)
private cert: Auth0Cert
) {}
fetchAccessToken(auth0: Authentication): Observable {
return Observable.create((obs: Observer) => {
auth0.oauthToken(
{
grantType: 'client_credentials',
audience: `https://${process.env.AUTH0_DOMAIN}/api/v2/`,
function App() {
this.webAuth = new Auth0.WebAuth({
domain: env.domain,
clientID: env.clientID
});
this.auth0 = new Auth0.Authentication(this.webAuth, {
domain: env.domain,
clientID: env.clientID
});
this.login = this.login.bind(this);
this.logout = this.logout.bind(this);
}
function App() {
this.auth0 = new Auth0.Authentication({
domain: env.domain,
clientID: env.clientID
});
this.login = this.login.bind(this);
this.logout = this.logout.bind(this);
}
const auth0 = require('auth0-js')
const auth = new auth0.Authentication({
domain: 'goodapi.auth0.com',
clientID: 'TCJ1lTepFTDAfxe1QjPB70vgVKqqwpCl'
});
/**
* Runs login command. Authenticate user against Auth0 and store necessary data ... TODO: which one?
*
* @param {string} username
* @param {string} password
*/
function login(username, password) {
auth.login({
realm: 'Username-Password-Authentication',
username,
password,
}, function(error, response) {
constructor() {
this.auth0 = new Auth0.Authentication({
domain: env.domain,
clientID: env.clientID
});
this.state = {
authenticated: false,
accessToken: false,
currentRoute: '/',
routes: {
'/': {
id: 'loading',
onMount: (page) => {
if (this.state.authenticated)
return this.redirectTo('/home');
return this.redirectTo('/login');
}
},
function CordovaAuth(options) {
this.clientId = options.clientId;
this.domain = options.domain;
this.redirectUri = options.packageIdentifier + '://' + options.domain + '/cordova/' + options.packageIdentifier + '/callback';
this.auth0 = new auth0.WebAuth({
clientID: this.clientId,
domain: this.domain
});
this.client = new auth0.Authentication(this.auth0, {
clientID: this.clientId,
domain: this.domain,
_telemetryInfo: telemetry
});
}
constructor(domain, clientID, redirectUri) {
if (!domain) {
throw new Error('You must provide an auth0 domain as the first parameter');
}
if (!clientID) {
throw new Error('You must provide a clientID');
}
if (!redirectUri) {
throw new Error('You must provide a clientID, which is used for building the AuthorizeURL and Exchange code for token');
}
this.keys = generateRandomChallengePair();
this.redirectUri = redirectUri;
this.client = new auth0.Authentication({
domain,
clientID
});
}
const Auth0 = require('auth0-js');
module.exports = new Auth0.Authentication({
domain: process.env['AUTH0_DOMAIN'],
clientID: process.env['AUTH0_CLIENT_ID'],
});