Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} from "@openid/appauth/built/token_request_handler";
import {
TokenError,
TokenResponse
} from "@openid/appauth/built/token_response";
import EventEmitter = require("events");
import { log } from "./logger";
import { StringMap } from "@openid/appauth/built/types";
export class AuthStateEmitter extends EventEmitter {
static ON_TOKEN_RESPONSE = "on_token_response";
}
/* the Node.js based HTTP client. */
const requestor = new NodeRequestor();
/* an example open id connect provider */
const openIdConnectUrl = "https://accounts.google.com";
/* example client configuration */
const clientId =
"511828570984-7nmej36h9j2tebiqmpqh835naet4vci4.apps.googleusercontent.com";
const redirectUri = "http://127.0.0.1:8000";
const scope = "openid";
export class AuthFlow {
private notifier: AuthorizationNotifier;
private authorizationHandler: AuthorizationRequestHandler;
private tokenHandler: TokenRequestHandler;
readonly authStateEmitter: AuthStateEmitter;
throw new Error('Configuration is not specified.');
}
log.debug(config);
log.debug(action);
log.debug(tokenStoreHander);
this.config = config;
this.action = action;
this.tokenStoreHander = tokenStoreHander || function(token) {log.debug(token);};
this.authConfiguration = new AuthorizationServiceConfiguration(
config.authorizationEndPoint,
config.tokenEndPoint
);
this.notifier = new AuthorizationNotifier();
this.authorizationHandler = new NodeBasedHandler(
config.redirectPort, new IoTHubQueryStringUtils());
this.requestor = new NodeRequestor();
this.tokenHandler = new IoTHubTokenRequestHandler(this.requestor);
this.authorizationHandler.setAuthorizationNotifier(this.notifier);
this.notifier.setAuthorizationListener((request, response, error) => {
if (error) {
log.error(error);
return this.action.invalidAccessToken(error);
}
if (response) {
if (this.authState !== response.state) {
return this.action.invalidAccessToken(resources.auth_msg_invalid_access_token);
}
this._performWithInitTokenRequest(response.code)
// .then(accessToken => this._performWithFreshTokens(accessToken))
.then(accessToken => {
log.debug(accessToken);
log.debug(accessToken.toJson);