Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@equinor/fusion-framework-module-msal

Package Overview
Dependencies
Maintainers
3
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equinor/fusion-framework-module-msal - npm Package Compare versions

Comparing version 0.1.0-beta.11 to 0.1.0-beta.12

client/package.json

35

dist/esm/provider.js

@@ -1,9 +0,11 @@

import { createAuthClient } from '@equinor/fusion-web-msal';
import { createAuthClient, ConsoleLogger } from './client';
const DEFAULT_CLIENT_NAME = 'default';
export class AuthProvider {
_config;
get client() {
return this.createClient();
_clients = {};
get defaultClient() {
return this.getClient(DEFAULT_CLIENT_NAME);
}
get account() {
return this.client.account;
get defaultAccount() {
return this.defaultClient.account;
}

@@ -16,2 +18,8 @@ get defaultConfig() {

}
getClient(name) {
if (!this._clients[name]) {
this._clients[name] = this.createClient(name);
}
return this._clients[name];
}
createClient(name) {

@@ -22,6 +30,17 @@ const config = name ? this._config.getClientConfig(name) : this._config.defaultConfig;

}
return createAuthClient(config.tenantId, config.clientId, config.redirectUri, config.config);
const client = createAuthClient(config.tenantId, config.clientId, config.redirectUri, config.config);
client.setLogger(new ConsoleLogger(3));
return client;
}
async handleRedirect() {
const { redirectUri } = this.defaultConfig || {};
if (window.location.pathname === redirectUri) {
const url = this.defaultClient.requestOrigin || '';
await this.defaultClient.handleRedirectPromise();
window.location.replace(url);
}
return null;
}
acquireToken(req) {
return this.createClient().acquireToken(req);
return this.defaultClient.acquireToken(req);
}

@@ -33,5 +52,5 @@ async acquireAccessToken(req) {

async login() {
await this.client.login();
await this.defaultClient.login();
}
}
//# sourceMappingURL=provider.js.map

@@ -1,2 +0,2 @@

import { AuthClientConfig } from '@equinor/fusion-web-msal';
import { AuthClientConfig } from './client';
export declare type AuthClientOptions = {

@@ -3,0 +3,0 @@ tenantId: string;

@@ -1,3 +0,2 @@

import { AuthClient } from '@equinor/fusion-web-msal';
import { AuthRequest } from '@equinor/fusion-web-msal/dist/request';
import { AuthClient, AuthRequest } from './client';
import { IAuthConfigurator, AuthClientOptions } from './configurator';

@@ -13,24 +12,25 @@ export declare type AccountInfo = {

export interface IAuthProvider {
readonly client: AuthClient;
readonly defaultClient: AuthClient;
readonly defaultConfig: AuthClientOptions | undefined;
readonly account: AccountInfo | undefined;
readonly defaultAccount: AccountInfo | undefined;
getClient(name: string): AuthClient;
createClient(name?: string): AuthClient;
acquireToken(req: AuthRequest): Promise<{
accessToken: string;
} | void>;
acquireToken(req: AuthRequest): ReturnType<AuthClient['acquireToken']>;
acquireAccessToken(req: AuthRequest): Promise<string | undefined>;
login(): Promise<void>;
handleRedirect(): ReturnType<AuthClient['handleRedirectPromise']>;
}
export declare class AuthProvider {
protected _config: IAuthConfigurator;
get client(): AuthClient;
get account(): AccountInfo | undefined;
protected _clients: Record<string, AuthClient>;
get defaultClient(): AuthClient;
get defaultAccount(): AccountInfo | undefined;
get defaultConfig(): AuthClientOptions | undefined;
constructor(_config: IAuthConfigurator);
getClient(name: string): AuthClient;
createClient(name?: string): AuthClient;
acquireToken(req: AuthRequest): Promise<{
accessToken: string;
} | void>;
handleRedirect(): ReturnType<AuthClient['handleRedirectPromise']>;
acquireToken(req: AuthRequest): ReturnType<AuthClient['acquireToken']>;
acquireAccessToken(req: AuthRequest): Promise<string | undefined>;
login(): Promise<void>;
}
{
"name": "@equinor/fusion-framework-module-msal",
"version": "0.1.0-beta.11",
"version": "0.1.0-beta.12",
"description": "",

@@ -24,5 +24,5 @@ "main": "./dist/esm/index.js",

"dependencies": {
"@equinor/fusion-framework-module": "^0.1.0-beta.11",
"@equinor/fusion-framework-module-http": "^0.1.0-beta.11",
"@equinor/fusion-web-msal": "^0.1.1"
"@azure/msal-browser": "^2.21.0",
"@equinor/fusion-framework-module": "^0.1.0-beta.12",
"@equinor/fusion-framework-module-http": "^0.1.0-beta.12"
},

@@ -37,3 +37,3 @@ "types": "index.d.ts",

},
"gitHead": "9eae0cf8b2761a727955a90a1cf41de6cc55da4a"
"gitHead": "1edabdde39b4815a9d56bf85748781986485d4fa"
}

@@ -1,2 +0,2 @@

import { AuthClientConfig } from '@equinor/fusion-web-msal';
import { AuthClientConfig } from './client';

@@ -3,0 +3,0 @@ export type AuthClientOptions = {

export * from './configurator';
export * from './provider';
export * from './module';
export { default } from './module';

@@ -1,6 +0,3 @@

import { AuthClient, createAuthClient } from '@equinor/fusion-web-msal';
import { AuthClient, createAuthClient, AuthRequest, ConsoleLogger } from './client';
// TODO
import { AuthRequest } from '@equinor/fusion-web-msal/dist/request';
import { IAuthConfigurator, AuthClientOptions } from './configurator';

@@ -19,18 +16,41 @@

export interface IAuthProvider {
readonly client: AuthClient;
readonly defaultClient: AuthClient;
readonly defaultConfig: AuthClientOptions | undefined;
readonly account: AccountInfo | undefined;
readonly defaultAccount: AccountInfo | undefined;
/**
* Get auth client by registered config name
*/
getClient(name: string): AuthClient;
/**
* Create auth client by registered config name
*/
createClient(name?: string): AuthClient;
acquireToken(req: AuthRequest): Promise<{ accessToken: string } | void>;
/**
* Acquire token from default auth client
*/
acquireToken(req: AuthRequest): ReturnType<AuthClient['acquireToken']>;
/**
* Acquire access token from default auth client
*/
acquireAccessToken(req: AuthRequest): Promise<string | undefined>;
/**
* Login to default auth client
*/
login(): Promise<void>;
/**
* Handle default client redirect callback
*/
handleRedirect(): ReturnType<AuthClient['handleRedirectPromise']>;
}
const DEFAULT_CLIENT_NAME = 'default';
export class AuthProvider {
get client(): AuthClient {
return this.createClient();
protected _clients: Record<string, AuthClient> = {};
get defaultClient(): AuthClient {
return this.getClient(DEFAULT_CLIENT_NAME);
}
get account(): AccountInfo | undefined {
return this.client.account;
get defaultAccount(): AccountInfo | undefined {
return this.defaultClient.account;
}

@@ -44,2 +64,9 @@

getClient(name: string): AuthClient {
if (!this._clients[name]) {
this._clients[name] = this.createClient(name);
}
return this._clients[name];
}
createClient(name?: string): AuthClient {

@@ -50,3 +77,3 @@ const config = name ? this._config.getClientConfig(name) : this._config.defaultConfig;

}
return createAuthClient(
const client = createAuthClient(
config.tenantId,

@@ -57,8 +84,22 @@ config.clientId,

);
// TODO - fix with log streamer
client.setLogger(new ConsoleLogger(3));
return client;
}
acquireToken(req: AuthRequest): Promise<{ accessToken: string } | void> {
return this.createClient().acquireToken(req);
async handleRedirect(): ReturnType<AuthClient['handleRedirectPromise']> {
const { redirectUri } = this.defaultConfig || {};
if (window.location.pathname === redirectUri) {
const url = this.defaultClient.requestOrigin || '';
await this.defaultClient.handleRedirectPromise();
window.location.replace(url);
}
return null;
}
acquireToken(req: AuthRequest): ReturnType<AuthClient['acquireToken']> {
return this.defaultClient.acquireToken(req);
}
async acquireAccessToken(req: AuthRequest): Promise<string | undefined> {

@@ -70,4 +111,4 @@ const token = await this.acquireToken(req);

async login(): Promise<void> {
await this.client.login();
await this.defaultClient.login();
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc