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

@azure/msal-react

Package Overview
Dependencies
Maintainers
3
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/msal-react - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

35

CHANGELOG.json

@@ -5,2 +5,37 @@ {

{
"date": "Mon, 28 Jun 2021 23:39:48 GMT",
"tag": "@azure/msal-react_v1.0.1",
"version": "1.0.1",
"comments": {
"none": [
{
"comment": "Component governance dependency updates #3655",
"author": "joarroyo@microsoft.com",
"commit": "d06ce5f5f4aa774e447d01e9cbf17d05a730bc47",
"package": "@azure/msal-react"
},
{
"comment": "fix: update package lock files",
"author": "samuelkamau@microsoft.com",
"commit": "0199e41269b79de70f7d0da0fb12448db534f784",
"package": "@azure/msal-react"
},
{
"comment": "Upgrade Jest to v27 #3719",
"author": "thomas.norling@microsoft.com",
"commit": "6c34aa5be3ee9536bd2febd2b7781fcdf0d28786",
"package": "@azure/msal-react"
}
],
"patch": [
{
"comment": "Change accounts context type to AccountInfo[] #3677",
"author": "thomas.norling@microsoft.com",
"commit": "5ba1ef16fac7b8f7c88505f86cef63f35044c817",
"package": "@azure/msal-react"
}
]
}
},
{
"date": "Thu, 13 May 2021 18:34:08 GMT",

@@ -7,0 +42,0 @@ "tag": "@azure/msal-react_v1.0.0",

10

CHANGELOG.md
# Change Log - @azure/msal-react
This log was last generated on Thu, 13 May 2021 18:34:08 GMT and should not be manually modified.
This log was last generated on Mon, 28 Jun 2021 23:39:48 GMT and should not be manually modified.
<!-- Start content -->
## 1.0.1
Mon, 28 Jun 2021 23:39:48 GMT
### Patches
- Change accounts context type to AccountInfo[] #3677 (thomas.norling@microsoft.com)
## 1.0.0

@@ -8,0 +16,0 @@

2

dist/msal-react.cjs.development.js

@@ -66,3 +66,3 @@ 'use strict';

const name = "@azure/msal-react";
const version = "1.0.0";
const version = "1.0.1";

@@ -69,0 +69,0 @@ /*

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,o=require("@azure/msal-browser");const c=t.createContext({instance:o.stubbedPublicClientApplication,inProgress:o.InteractionStatus.None,accounts:[],logger:new o.Logger({})}),r=c.Consumer;function a(e,t){return"function"==typeof e?e(t):e}const s=()=>t.useContext(c);function u(e,t){const n=e.getAllAccounts();return n.length>0&&(t.homeAccountId||t.localAccountId||t.username)&&n.filter(e=>!(t.username&&t.username.toLowerCase()!==e.username.toLowerCase()||t.homeAccountId&&t.homeAccountId.toLowerCase()!==e.homeAccountId.toLowerCase()||t.localAccountId&&t.localAccountId.toLowerCase()!==e.localAccountId.toLowerCase()))[0]||null}function l(e){const{instance:n,inProgress:c}=s(),r=c===o.InteractionStatus.Startup?null:u(n,e),[a,l]=t.useState(r);return t.useEffect(()=>{const t=u(n,e);o.AccountEntity.accountInfoIsEqual(a,t,!0)||l(t)},[c,e,n,a]),a}function i(e,t,n){return n&&(n.username||n.homeAccountId||n.localAccountId)?!!t:e.length>0}function d(e){const{accounts:n,inProgress:c}=s(),r=l(e||{}),a=c!==o.InteractionStatus.Startup&&i(n,r,e),[u,d]=t.useState(a);return t.useEffect(()=>{d(i(n,r,e))},[n,r,e]),u}function p(e,n,c){const{instance:r,inProgress:a,logger:u}=s(),l=d(c),[[i,p],m]=t.useState([null,null]),[I,v]=t.useState(!1),E=t.useCallback(async(t,c)=>{const a=c||n;switch(t||e){case o.InteractionType.Popup:return u.verbose("useMsalAuthentication - Calling loginPopup"),r.loginPopup(a);case o.InteractionType.Redirect:return u.verbose("useMsalAuthentication - Calling loginRedirect"),r.loginRedirect(a).then(null);case o.InteractionType.Silent:return u.verbose("useMsalAuthentication - Calling ssoSilent"),r.ssoSilent(a);default:throw"Invalid interaction type provided."}},[r,e,n,u]);return t.useEffect(()=>{const e=r.addEventCallback(e=>{switch(e.eventType){case o.EventType.LOGIN_SUCCESS:case o.EventType.SSO_SILENT_SUCCESS:e.payload&&m([e.payload,null]);break;case o.EventType.LOGIN_FAILURE:case o.EventType.SSO_SILENT_FAILURE:e.error&&m([null,e.error])}});return u.verbose("useMsalAuthentication - Registered event callback with id: "+e),()=>{e&&(u.verbose("useMsalAuthentication - Removing event callback "+e),r.removeEventCallback(e))}},[r,u]),t.useEffect(()=>{I||p||l||a!==o.InteractionStatus.None||(u.info("useMsalAuthentication - No user is authenticated, attempting to login"),v(!0),E().catch(()=>{}))},[l,a,p,I,E,u]),{login:E,result:i,error:p}}exports.AuthenticatedTemplate=function({username:e,homeAccountId:c,localAccountId:r,children:u}){const l=s();return d(t.useMemo(()=>({username:e,homeAccountId:c,localAccountId:r}),[e,c,r]))&&l.inProgress!==o.InteractionStatus.Startup?n.createElement(n.Fragment,null,a(u,l)):null},exports.MsalAuthenticationTemplate=function({interactionType:e,username:c,homeAccountId:r,localAccountId:u,authenticationRequest:l,loadingComponent:i,errorComponent:m,children:I}){const v=t.useMemo(()=>({username:c,homeAccountId:r,localAccountId:u}),[c,r,u]),E=s(),g=p(e,l,v),S=d(v);if(g.error&&E.inProgress===o.InteractionStatus.None){if(m)return n.createElement(m,Object.assign({},g));throw g.error}return S?n.createElement(n.Fragment,null,a(I,g)):i&&E.inProgress!==o.InteractionStatus.None?n.createElement(i,Object.assign({},E)):null},exports.MsalConsumer=r,exports.MsalContext=c,exports.MsalProvider=function({instance:e,children:r}){t.useEffect(()=>{e.initializeWrapperLibrary(o.WrapperSKU.React,"1.0.0")},[e]);const a=t.useMemo(()=>e.getLogger().clone("@azure/msal-react","1.0.0"),[e]),[s,u]=t.useState([]),[l,i]=t.useState(o.InteractionStatus.Startup);return t.useEffect(()=>{const t=e.addEventCallback(t=>{switch(t.eventType){case o.EventType.LOGIN_SUCCESS:case o.EventType.SSO_SILENT_SUCCESS:case o.EventType.HANDLE_REDIRECT_END:case o.EventType.LOGIN_FAILURE:case o.EventType.SSO_SILENT_FAILURE:case o.EventType.LOGOUT_END:case o.EventType.ACQUIRE_TOKEN_SUCCESS:case o.EventType.ACQUIRE_TOKEN_FAILURE:const t=e.getAllAccounts();!function(e,t){if(e.length!==t.length)return!1;const n=[...t];return e.every(e=>{const t=n.shift();return!(!e||!t)&&e.homeAccountId===t.homeAccountId&&e.localAccountId===t.localAccountId&&e.username===t.username})}(t,s)?(a.info("MsalProvider - updating account state"),u(t)):a.info("MsalProvider - no account changes")}});return a.verbose("MsalProvider - Registered event callback with id: "+t),()=>{t&&(a.verbose("MsalProvider - Removing event callback "+t),e.removeEventCallback(t))}},[e,s,a]),t.useEffect(()=>{const t=e.addEventCallback(e=>{const t=o.EventMessageUtils.getInteractionStatusFromEvent(e);null!==t&&(a.info(`MsalProvider - ${e.eventType} results in setting inProgress to ${t}`),i(t))});return a.verbose("MsalProvider - Registered event callback with id: "+t),e.handleRedirectPromise().catch(()=>{}),()=>{t&&(a.verbose("MsalProvider - Removing event callback "+t),e.removeEventCallback(t))}},[e,a]),n.createElement(c.Provider,{value:{instance:e,inProgress:l,accounts:s,logger:a}},r)},exports.UnauthenticatedTemplate=function({username:e,homeAccountId:c,localAccountId:r,children:u}){const l=s();return d(t.useMemo(()=>({username:e,homeAccountId:c,localAccountId:r}),[e,c,r]))||l.inProgress===o.InteractionStatus.Startup||l.inProgress===o.InteractionStatus.HandleRedirect?null:n.createElement(n.Fragment,null,a(u,l))},exports.useAccount=l,exports.useIsAuthenticated=d,exports.useMsal=s,exports.useMsalAuthentication=p,exports.withMsal=e=>{const t=t=>{const o=s();return n.createElement(e,Object.assign({},t,{msalContext:o}))};return t.displayName=`withMsal(${e.displayName||e.name||"Component"})`,t};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,o=require("@azure/msal-browser");const c=t.createContext({instance:o.stubbedPublicClientApplication,inProgress:o.InteractionStatus.None,accounts:[],logger:new o.Logger({})}),r=c.Consumer;function a(e,t){return"function"==typeof e?e(t):e}const s=()=>t.useContext(c);function u(e,t){const n=e.getAllAccounts();return n.length>0&&(t.homeAccountId||t.localAccountId||t.username)&&n.filter(e=>!(t.username&&t.username.toLowerCase()!==e.username.toLowerCase()||t.homeAccountId&&t.homeAccountId.toLowerCase()!==e.homeAccountId.toLowerCase()||t.localAccountId&&t.localAccountId.toLowerCase()!==e.localAccountId.toLowerCase()))[0]||null}function l(e){const{instance:n,inProgress:c}=s(),r=c===o.InteractionStatus.Startup?null:u(n,e),[a,l]=t.useState(r);return t.useEffect(()=>{const t=u(n,e);o.AccountEntity.accountInfoIsEqual(a,t,!0)||l(t)},[c,e,n,a]),a}function i(e,t,n){return n&&(n.username||n.homeAccountId||n.localAccountId)?!!t:e.length>0}function d(e){const{accounts:n,inProgress:c}=s(),r=l(e||{}),a=c!==o.InteractionStatus.Startup&&i(n,r,e),[u,d]=t.useState(a);return t.useEffect(()=>{d(i(n,r,e))},[n,r,e]),u}function p(e,n,c){const{instance:r,inProgress:a,logger:u}=s(),l=d(c),[[i,p],m]=t.useState([null,null]),[I,v]=t.useState(!1),E=t.useCallback(async(t,c)=>{const a=c||n;switch(t||e){case o.InteractionType.Popup:return u.verbose("useMsalAuthentication - Calling loginPopup"),r.loginPopup(a);case o.InteractionType.Redirect:return u.verbose("useMsalAuthentication - Calling loginRedirect"),r.loginRedirect(a).then(null);case o.InteractionType.Silent:return u.verbose("useMsalAuthentication - Calling ssoSilent"),r.ssoSilent(a);default:throw"Invalid interaction type provided."}},[r,e,n,u]);return t.useEffect(()=>{const e=r.addEventCallback(e=>{switch(e.eventType){case o.EventType.LOGIN_SUCCESS:case o.EventType.SSO_SILENT_SUCCESS:e.payload&&m([e.payload,null]);break;case o.EventType.LOGIN_FAILURE:case o.EventType.SSO_SILENT_FAILURE:e.error&&m([null,e.error])}});return u.verbose("useMsalAuthentication - Registered event callback with id: "+e),()=>{e&&(u.verbose("useMsalAuthentication - Removing event callback "+e),r.removeEventCallback(e))}},[r,u]),t.useEffect(()=>{I||p||l||a!==o.InteractionStatus.None||(u.info("useMsalAuthentication - No user is authenticated, attempting to login"),v(!0),E().catch(()=>{}))},[l,a,p,I,E,u]),{login:E,result:i,error:p}}exports.AuthenticatedTemplate=function({username:e,homeAccountId:c,localAccountId:r,children:u}){const l=s();return d(t.useMemo(()=>({username:e,homeAccountId:c,localAccountId:r}),[e,c,r]))&&l.inProgress!==o.InteractionStatus.Startup?n.createElement(n.Fragment,null,a(u,l)):null},exports.MsalAuthenticationTemplate=function({interactionType:e,username:c,homeAccountId:r,localAccountId:u,authenticationRequest:l,loadingComponent:i,errorComponent:m,children:I}){const v=t.useMemo(()=>({username:c,homeAccountId:r,localAccountId:u}),[c,r,u]),E=s(),g=p(e,l,v),S=d(v);if(g.error&&E.inProgress===o.InteractionStatus.None){if(m)return n.createElement(m,Object.assign({},g));throw g.error}return S?n.createElement(n.Fragment,null,a(I,g)):i&&E.inProgress!==o.InteractionStatus.None?n.createElement(i,Object.assign({},E)):null},exports.MsalConsumer=r,exports.MsalContext=c,exports.MsalProvider=function({instance:e,children:r}){t.useEffect(()=>{e.initializeWrapperLibrary(o.WrapperSKU.React,"1.0.1")},[e]);const a=t.useMemo(()=>e.getLogger().clone("@azure/msal-react","1.0.1"),[e]),[s,u]=t.useState([]),[l,i]=t.useState(o.InteractionStatus.Startup);return t.useEffect(()=>{const t=e.addEventCallback(t=>{switch(t.eventType){case o.EventType.LOGIN_SUCCESS:case o.EventType.SSO_SILENT_SUCCESS:case o.EventType.HANDLE_REDIRECT_END:case o.EventType.LOGIN_FAILURE:case o.EventType.SSO_SILENT_FAILURE:case o.EventType.LOGOUT_END:case o.EventType.ACQUIRE_TOKEN_SUCCESS:case o.EventType.ACQUIRE_TOKEN_FAILURE:const t=e.getAllAccounts();!function(e,t){if(e.length!==t.length)return!1;const n=[...t];return e.every(e=>{const t=n.shift();return!(!e||!t)&&e.homeAccountId===t.homeAccountId&&e.localAccountId===t.localAccountId&&e.username===t.username})}(t,s)?(a.info("MsalProvider - updating account state"),u(t)):a.info("MsalProvider - no account changes")}});return a.verbose("MsalProvider - Registered event callback with id: "+t),()=>{t&&(a.verbose("MsalProvider - Removing event callback "+t),e.removeEventCallback(t))}},[e,s,a]),t.useEffect(()=>{const t=e.addEventCallback(e=>{const t=o.EventMessageUtils.getInteractionStatusFromEvent(e);null!==t&&(a.info(`MsalProvider - ${e.eventType} results in setting inProgress to ${t}`),i(t))});return a.verbose("MsalProvider - Registered event callback with id: "+t),e.handleRedirectPromise().catch(()=>{}),()=>{t&&(a.verbose("MsalProvider - Removing event callback "+t),e.removeEventCallback(t))}},[e,a]),n.createElement(c.Provider,{value:{instance:e,inProgress:l,accounts:s,logger:a}},r)},exports.UnauthenticatedTemplate=function({username:e,homeAccountId:c,localAccountId:r,children:u}){const l=s();return d(t.useMemo(()=>({username:e,homeAccountId:c,localAccountId:r}),[e,c,r]))||l.inProgress===o.InteractionStatus.Startup||l.inProgress===o.InteractionStatus.HandleRedirect?null:n.createElement(n.Fragment,null,a(u,l))},exports.useAccount=l,exports.useIsAuthenticated=d,exports.useMsal=s,exports.useMsalAuthentication=p,exports.withMsal=e=>{const t=t=>{const o=s();return n.createElement(e,Object.assign({},t,{msalContext:o}))};return t.displayName=`withMsal(${e.displayName||e.name||"Component"})`,t};
//# sourceMappingURL=msal-react.cjs.production.min.js.map

@@ -59,3 +59,3 @@ import React__default, { createContext, useEffect, useMemo, useState, useContext, useCallback } from 'react';

const name = "@azure/msal-react";
const version = "1.0.0";
const version = "1.0.1";

@@ -62,0 +62,0 @@ /*

import * as React from "react";
import { IPublicClientApplication, Logger, InteractionStatus } from "@azure/msal-browser";
import { AccountIdentifiers } from "./types/AccountIdentifiers";
import { IPublicClientApplication, Logger, InteractionStatus, AccountInfo } from "@azure/msal-browser";
export interface IMsalContext {
instance: IPublicClientApplication;
inProgress: InteractionStatus;
accounts: AccountIdentifiers[];
accounts: AccountInfo[];
logger: Logger;

@@ -9,0 +8,0 @@ }

export declare const name = "@azure/msal-react";
export declare const version = "1.0.0";
export declare const version = "1.0.1";
{
"name": "@azure/msal-react",
"version": "1.0.0",
"version": "1.0.1",
"author": {

@@ -38,3 +38,3 @@ "name": "Microsoft",

"peerDependencies": {
"@azure/msal-browser": "^2.14.2",
"@azure/msal-browser": "^2.15.0",
"react": "^16.13.0 || ^17"

@@ -44,3 +44,3 @@ },

"devDependencies": {
"@azure/msal-browser": "^2.14.2",
"@azure/msal-browser": "^2.15.0",
"@testing-library/jest-dom": "^5.11.5",

@@ -51,7 +51,7 @@ "@testing-library/react": "^11.2.3",

"@types/react-dom": "^16.9.8",
"jest": "^26.6.1",
"jest": "^27.0.4",
"jest-environment-jsdom-fifteen": "^1.0.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"ts-jest": "^26.4.3",
"ts-jest": "^27.0.2",
"tsdx": "^0.14.1",

@@ -58,0 +58,0 @@ "tslib": "^2.0.0",

# Microsoft Authentication Library for React (msal-react)
[![npm version](https://img.shields.io/npm/v/@azure/msal-react.svg?style=flat)](https://www.npmjs.com/package/@azure/msal-react/)[![npm version](https://img.shields.io/npm/dm/@azure/msal-react.svg)](https://nodei.co/npm/@azure/msal-react/)
[![npm version](https://img.shields.io/npm/v/@azure/msal-react.svg?style=flat)](https://www.npmjs.com/package/@azure/msal-react/)
[![npm version](https://img.shields.io/npm/dm/@azure/msal-react.svg)](https://nodei.co/npm/@azure/msal-react/)
[![codecov](https://codecov.io/gh/AzureAD/microsoft-authentication-library-for-js/branch/dev/graph/badge.svg?flag=msal-react)](https://codecov.io/gh/AzureAD/microsoft-authentication-library-for-js)

@@ -123,2 +125,9 @@ | <a href="https://docs.microsoft.com/azure/active-directory/develop/tutorial-v2-react" target="blank">Getting Started</a> | <a href="https://aka.ms/aaddevv2" target="_blank">AAD Docs</a> | <a href="https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_react.html" target="_blank">Library Reference</a> | <a href="https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples" target="blank">Samples</a>

More advanced samples backed with a tutorial can be found in the [Azure Samples](https://github.com/Azure-Samples) space on GitHub:
- [React SPA calling Express.js web API](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/3-Authorization-II/1-call-api)
- [React SPA calling Express.js web API using Proof of Possesion tokens](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/6-AdvancedScenarios/2-call-api-pop)
- [React SPA calling Microsoft Graph via Express.js web API using on-behalf-of flow](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/6-AdvancedScenarios/1-call-api-obo)
- [Deployment tutorial for Azure Static Web Apps](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/4-Deployment/2-deploy-static)
## Security Reporting

@@ -125,0 +134,0 @@

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

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