Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(private readonly _settings: AuthorizeServiceConfiguration) {
// It is important that we capture the callback-url here as msal will remove the auth parameters
// from the url as soon as it gets initialized.
const callbackUrl = location.href;
this._msalApplication = new Msal.UserAgentApplication(this._settings);
// This promise will only resolve in callback-paths, which is where we check it.
this._callbackPromise = this.createCallbackResult(callbackUrl);
}
}
this.msalConfig = {
auth: {
clientId: options.clientId!, // we just initialized it above
authority: `${options.authorityHost}/${options.tenantId}`,
...(options.redirectUri && { redirectUri: options.redirectUri }),
...(options.postLogoutRedirectUri && { redirectUri: options.postLogoutRedirectUri })
},
cache: {
cacheLocation: "localStorage",
storeAuthStateInCookie: true
}
};
this.msalObject = new msal.UserAgentApplication(this.msalConfig);
}
constructor() {
// The window values below should by set by public/js/settings.js
this._scopes = window.authScopes;
this._clientId = window.authClientId;
this._authority = window.authAuthority;
var cb = this._tokenCallback.bind(this);
var opts = {
validateAuthority: false
};
this._userAgentApplication = new UserAgentApplication(
this._clientId,
this._authority,
cb,
opts
);
}
this.init = function (configOptions, httpProvider) {
if (configOptions) {
_config = configOptions;
if (!configOptions.optionalParams) {
configOptions.optionalParams = {};
}
configOptions.optionalParams.isAngular = true;
if (httpProvider && httpProvider.interceptors) {
httpProvider.interceptors.push('ProtectedResourceInterceptor');
}
// create instance with given config
_msal = new Msal.UserAgentApplication(configOptions.clientID, configOptions.authority, configOptions.tokenReceivedCallback, configOptions.optionalParams);
if (configOptions.routeProtectionConfig) {
_msal.routeProtectionConfig = configOptions.routeProtectionConfig;
}
else {
_msal.routeProtectionConfig = {};
}
_msal.loginScopes = [_msal.clientId];
_constants = Msal.Constants;
} else {
throw new Error('You must set configOptions, when calling init');
}
// loginResource is used to set authenticated status
updateDataFromCache(_msal.loginScopes);
};
constructor(clientId: string, scopes: string[] = ["user.read"], authority: string = null, options: any = null) {
this.type = ProviderType.V2;
this.provider = new UserAgentApplication(clientId, authority, this.tokenReceivedCallback);
this.scopes = scopes;
}
constructor() {
this.clientApplication =
new Msal.UserAgentApplication(
environment.clientID,
this.authority,
this.authCallback);
}
if (config.clientId) {
const msalConfig: Configuration = config.options || { auth: { clientId: config.clientId } };
msalConfig.auth.clientId = config.clientId;
msalConfig.cache = msalConfig.cache || {};
msalConfig.cache.cacheLocation = msalConfig.cache.cacheLocation || 'localStorage';
msalConfig.cache.storeAuthStateInCookie = msalConfig.cache.storeAuthStateInCookie || true;
if (config.authority) {
msalConfig.auth.authority = config.authority;
}
this.clientId = config.clientId;
this._userAgentApplication = new UserAgentApplication(msalConfig);
this._userAgentApplication.handleRedirectCallback(tokenReceivedCallbackFunction, errorReceivedCallbackFunction);
} else {
throw new Error('clientId must be provided');
}
this.graph = new Graph(this);
this.trySilentSignIn();
}
function MSALAuthenticationProvider(clientId, scopes, options) {
var callback = function (errorDesc, token, error, tokenType) {
};
var self = this;
self.clientId = clientId;
self.scopes = scopes;
self.userAgentApplication = new msal_1.UserAgentApplication(self.clientId, undefined, callback, options);
}
/**