This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@equinor/fusion-web-msal
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@equinor/fusion-web-msal

Light wrapper of Microsoft official msal library

Behavior

By default the client will try to uses a hidden iframe to fetch an authorization code from the eSTS.

There are cases where this may not work:

  • Any browser using a form of Intelligent Tracking Prevention
  • If there is not an established session with the service
  • For the cases where interaction is required, you cannot send a request with prompt=none

Popup

Use when initiating the login process via opening a popup window in the user's browser

Redirect

This function redirects the page, so any code that follows this function will not execute.

IMPORTANT: It is NOT recommended to have code that is dependent on the resolution of the Promise. This function will navigate away from the current browser window. It currently returns a Promise in order to reflect the asynchronous nature of the code running in this function.

Usage

Basic

import { createAuthClient } from '@equinor/fusion-web-msal';

const main = async () => {
  const authPath = '/my-app/auth';
  const client = createAuthClient(
    'azure-tennant-id',
    'azure-client-id'
    authPath
  });

  if(window.location.path === authPath) {
    await client.handleRedirectPromise();
  }

  if(!client.account){
    await auth.login();
  }

  const token = await client.acquireToken({
    scopes: ['email'],
  });

  if (!token) throw Error('failed to fetch token');

  fetch('https://my-server.not/api/bogus', {
    headers: {
      Authorization: `Bearer ${token.accessToken}`,
    },
  });
};

main();

Popup

auth.login('popup');
auth.acquireToken('popup');

Redirect

auth.login('redirect');
auth.acquireToken('redirect');

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Published

Version History

  • Version
    Downloads (Last 7 Days)
    • Published

Package Sidebar

Install

npm i @equinor/fusion-web-msal

Weekly Downloads

26

Version

0.1.1

License

ISC

Unpacked Size

31.8 kB

Total Files

24

Last publish

Collaborators

  • _odin_
  • eslsa
  • gustav-eikaas
  • martinforre