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.5.1 to 1.5.2

2

dist/msal-react.cjs.development.js

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

const name = "@azure/msal-react";
const version = "1.5.1";
const version = "1.5.2";

@@ -91,0 +91,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,r=require("@azure/msal-browser");const o=t.createContext({instance:r.stubbedPublicClientApplication,inProgress:r.InteractionStatus.None,accounts:[],logger:new r.Logger({})}),c=o.Consumer;function a(e,t){return"function"==typeof e?e(t):e}function s(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})}function i(e,t){return e.length>0&&(t.homeAccountId||t.localAccountId||t.username)&&e.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}var u;!function(e){e.UNBLOCK_INPROGRESS="UNBLOCK_INPROGRESS",e.EVENT="EVENT"}(u||(u={}));const l=(e,t)=>{const{type:n,payload:o}=t;let c=e.inProgress;switch(n){case u.UNBLOCK_INPROGRESS:e.inProgress===r.InteractionStatus.Startup&&(c=r.InteractionStatus.None,o.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));break;case u.EVENT:const t=o.message,a=r.EventMessageUtils.getInteractionStatusFromEvent(t,e.inProgress);a&&(o.logger.info(`MsalProvider - ${t.eventType} results in setting inProgress from ${e.inProgress} to ${a}`),c=a);break;default:throw new Error("Unknown action type: "+n)}const a=o.instance.getAllAccounts();return c===e.inProgress||s(a,e.accounts)?c!==e.inProgress?{...e,inProgress:c}:s(a,e.accounts)?e:{...e,accounts:a}:{...e,inProgress:c,accounts:a}},d=()=>t.useContext(o);function g(e,t){return t&&(t.username||t.homeAccountId||t.localAccountId)?!!i(e,t):e.length>0}function p(e){const{accounts:n,inProgress:o}=d(),[c,a]=t.useState(()=>o!==r.InteractionStatus.Startup&&g(n,e));return t.useEffect(()=>{a(g(n,e))},[n,e]),c}function h(e,t){return t&&(t.homeAccountId||t.localAccountId||t.username)?i(e.getAllAccounts(),t):e.getActiveAccount()}function m(e){const{instance:n,inProgress:o,logger:c}=d(),[a,s]=t.useState(()=>h(n,e));return t.useEffect(()=>{s(t=>{const o=h(n,e);return r.AccountEntity.accountInfoIsEqual(t,o,!0)?t:(c.info("useAccount - Updating account"),o)})},[o,e,n,c]),a}class I extends r.AuthError{constructor(e,t){super(e,t),Object.setPrototypeOf(this,I.prototype),this.name="ReactAuthError"}static createInvalidInteractionTypeError(){return new I("invalid_interaction_type","The provided interaction type is invalid.")}static createUnableToFallbackToInteractionError(){return new I("unable_to_fallback_to_interaction","Interaction is required but another interaction is already in progress. Please try again when the current interaction is complete.")}}function A(e,n,o){const{instance:c,inProgress:a,logger:s}=d(),i=p(o),u=m(o),[[l,g],h]=t.useState([null,null]),A=t.useRef(!0);t.useEffect(()=>()=>{A.current=!1},[]);const f=t.useRef(a!==r.InteractionStatus.None);t.useEffect(()=>{f.current=a!==r.InteractionStatus.None},[a]);const E=t.useRef(!0);t.useEffect(()=>{(g||l)&&(E.current=!1)},[g,l]);const S=t.useCallback(async(t,o)=>{const a=o||n;switch(t||e){case r.InteractionType.Popup:return s.verbose("useMsalAuthentication - Calling loginPopup"),c.loginPopup(a);case r.InteractionType.Redirect:return s.verbose("useMsalAuthentication - Calling loginRedirect"),c.loginRedirect(a).then(null);case r.InteractionType.Silent:return s.verbose("useMsalAuthentication - Calling ssoSilent"),c.ssoSilent(a);default:throw I.createInvalidInteractionTypeError()}},[c,e,n,s]),v=t.useCallback(async(t,o)=>{const a=t||e;let i;return o?(s.trace("useMsalAuthentication - acquireToken - Using request provided in the callback"),i={...o}):n?(s.trace("useMsalAuthentication - acquireToken - Using request provided in the hook"),i={...n,scopes:n.scopes||r.OIDC_DEFAULT_SCOPES}):(s.trace("useMsalAuthentication - acquireToken - No request object provided, using default request."),i={scopes:r.OIDC_DEFAULT_SCOPES}),!i.account&&u&&(s.trace("useMsalAuthentication - acquireToken - Attaching account to request"),i.account=u),(async()=>(s.verbose("useMsalAuthentication - Calling acquireTokenSilent"),c.acquireTokenSilent(i).catch(async e=>{if(e instanceof r.InteractionRequiredAuthError){if(f.current)throw s.error("useMsalAuthentication - Interaction required but is already in progress. Please try again, if needed, after interaction completes."),I.createUnableToFallbackToInteractionError();return s.error("useMsalAuthentication - Interaction required, falling back to interaction"),S(a,i)}throw e})))().then(e=>(A.current&&h([e,null]),e)).catch(e=>{throw A.current&&h([null,e]),e})},[c,e,n,s,u,S]);return t.useEffect(()=>{const e=c.addEventCallback(e=>{switch(e.eventType){case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:e.payload&&h([e.payload,null]);break;case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:e.error&&h([null,e.error])}});return s.verbose("useMsalAuthentication - Registered event callback with id: "+e),()=>{e&&(s.verbose("useMsalAuthentication - Removing event callback "+e),c.removeEventCallback(e))}},[c,s]),t.useEffect(()=>{E.current&&a===r.InteractionStatus.None&&(E.current=!1,i?u&&(s.info("useMsalAuthentication - User is authenticated, attempting to acquire token"),v().catch(()=>{})):(s.info("useMsalAuthentication - No user is authenticated, attempting to login"),S().catch(()=>{})))},[i,u,a,S,v,s]),{login:S,acquireToken:v,result:l,error:g}}exports.AuthenticatedTemplate=function(e){let{username:o,homeAccountId:c,localAccountId:s,children:i}=e;const u=d();return p(t.useMemo(()=>({username:o,homeAccountId:c,localAccountId:s}),[o,c,s]))&&u.inProgress!==r.InteractionStatus.Startup?n.createElement(n.Fragment,null,a(i,u)):null},exports.MsalAuthenticationTemplate=function(e){let{interactionType:o,username:c,homeAccountId:s,localAccountId:i,authenticationRequest:u,loadingComponent:l,errorComponent:g,children:h}=e;const m=t.useMemo(()=>({username:c,homeAccountId:s,localAccountId:i}),[c,s,i]),I=d(),f=A(o,u,m),E=p(m);if(f.error&&I.inProgress===r.InteractionStatus.None){if(g)return n.createElement(g,Object.assign({},f));throw f.error}return E?n.createElement(n.Fragment,null,a(h,f)):l&&I.inProgress!==r.InteractionStatus.None?n.createElement(l,Object.assign({},I)):null},exports.MsalConsumer=c,exports.MsalContext=o,exports.MsalProvider=function(e){let{instance:c,children:a}=e;t.useEffect(()=>{c.initializeWrapperLibrary(r.WrapperSKU.React,"1.5.1")},[c]);const s=t.useMemo(()=>c.getLogger().clone("@azure/msal-react","1.5.1"),[c]),[i,d]=t.useReducer(l,void 0,()=>({inProgress:r.InteractionStatus.Startup,accounts:c.getAllAccounts()}));return t.useEffect(()=>{const e=c.addEventCallback(e=>{d({payload:{instance:c,logger:s,message:e},type:u.EVENT})});return s.verbose("MsalProvider - Registered event callback with id: "+e),c.initialize().then(()=>{c.handleRedirectPromise().catch(()=>{}).finally(()=>{d({payload:{instance:c,logger:s},type:u.UNBLOCK_INPROGRESS})})}),()=>{e&&(s.verbose("MsalProvider - Removing event callback "+e),c.removeEventCallback(e))}},[c,s]),n.createElement(o.Provider,{value:{instance:c,inProgress:i.inProgress,accounts:i.accounts,logger:s}},a)},exports.UnauthenticatedTemplate=function(e){let{username:o,homeAccountId:c,localAccountId:s,children:i}=e;const u=d();return p(t.useMemo(()=>({username:o,homeAccountId:c,localAccountId:s}),[o,c,s]))||u.inProgress===r.InteractionStatus.Startup||u.inProgress===r.InteractionStatus.HandleRedirect?null:n.createElement(n.Fragment,null,a(i,u))},exports.useAccount=m,exports.useIsAuthenticated=p,exports.useMsal=d,exports.useMsalAuthentication=A,exports.version="1.5.1",exports.withMsal=e=>{const t=t=>{const r=d();return n.createElement(e,Object.assign({},t,{msalContext:r}))};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,r=require("@azure/msal-browser");const o=t.createContext({instance:r.stubbedPublicClientApplication,inProgress:r.InteractionStatus.None,accounts:[],logger:new r.Logger({})}),c=o.Consumer;function a(e,t){return"function"==typeof e?e(t):e}function s(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})}function i(e,t){return e.length>0&&(t.homeAccountId||t.localAccountId||t.username)&&e.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}var u;!function(e){e.UNBLOCK_INPROGRESS="UNBLOCK_INPROGRESS",e.EVENT="EVENT"}(u||(u={}));const l=(e,t)=>{const{type:n,payload:o}=t;let c=e.inProgress;switch(n){case u.UNBLOCK_INPROGRESS:e.inProgress===r.InteractionStatus.Startup&&(c=r.InteractionStatus.None,o.logger.info("MsalProvider - handleRedirectPromise resolved, setting inProgress to 'none'"));break;case u.EVENT:const t=o.message,a=r.EventMessageUtils.getInteractionStatusFromEvent(t,e.inProgress);a&&(o.logger.info(`MsalProvider - ${t.eventType} results in setting inProgress from ${e.inProgress} to ${a}`),c=a);break;default:throw new Error("Unknown action type: "+n)}const a=o.instance.getAllAccounts();return c===e.inProgress||s(a,e.accounts)?c!==e.inProgress?{...e,inProgress:c}:s(a,e.accounts)?e:{...e,accounts:a}:{...e,inProgress:c,accounts:a}},d=()=>t.useContext(o);function g(e,t){return t&&(t.username||t.homeAccountId||t.localAccountId)?!!i(e,t):e.length>0}function p(e){const{accounts:n,inProgress:o}=d(),[c,a]=t.useState(()=>o!==r.InteractionStatus.Startup&&g(n,e));return t.useEffect(()=>{a(g(n,e))},[n,e]),c}function h(e,t){return t&&(t.homeAccountId||t.localAccountId||t.username)?i(e.getAllAccounts(),t):e.getActiveAccount()}function m(e){const{instance:n,inProgress:o,logger:c}=d(),[a,s]=t.useState(()=>h(n,e));return t.useEffect(()=>{s(t=>{const o=h(n,e);return r.AccountEntity.accountInfoIsEqual(t,o,!0)?t:(c.info("useAccount - Updating account"),o)})},[o,e,n,c]),a}class I extends r.AuthError{constructor(e,t){super(e,t),Object.setPrototypeOf(this,I.prototype),this.name="ReactAuthError"}static createInvalidInteractionTypeError(){return new I("invalid_interaction_type","The provided interaction type is invalid.")}static createUnableToFallbackToInteractionError(){return new I("unable_to_fallback_to_interaction","Interaction is required but another interaction is already in progress. Please try again when the current interaction is complete.")}}function A(e,n,o){const{instance:c,inProgress:a,logger:s}=d(),i=p(o),u=m(o),[[l,g],h]=t.useState([null,null]),A=t.useRef(!0);t.useEffect(()=>()=>{A.current=!1},[]);const f=t.useRef(a!==r.InteractionStatus.None);t.useEffect(()=>{f.current=a!==r.InteractionStatus.None},[a]);const E=t.useRef(!0);t.useEffect(()=>{(g||l)&&(E.current=!1)},[g,l]);const S=t.useCallback(async(t,o)=>{const a=o||n;switch(t||e){case r.InteractionType.Popup:return s.verbose("useMsalAuthentication - Calling loginPopup"),c.loginPopup(a);case r.InteractionType.Redirect:return s.verbose("useMsalAuthentication - Calling loginRedirect"),c.loginRedirect(a).then(null);case r.InteractionType.Silent:return s.verbose("useMsalAuthentication - Calling ssoSilent"),c.ssoSilent(a);default:throw I.createInvalidInteractionTypeError()}},[c,e,n,s]),v=t.useCallback(async(t,o)=>{const a=t||e;let i;return o?(s.trace("useMsalAuthentication - acquireToken - Using request provided in the callback"),i={...o}):n?(s.trace("useMsalAuthentication - acquireToken - Using request provided in the hook"),i={...n,scopes:n.scopes||r.OIDC_DEFAULT_SCOPES}):(s.trace("useMsalAuthentication - acquireToken - No request object provided, using default request."),i={scopes:r.OIDC_DEFAULT_SCOPES}),!i.account&&u&&(s.trace("useMsalAuthentication - acquireToken - Attaching account to request"),i.account=u),(async()=>(s.verbose("useMsalAuthentication - Calling acquireTokenSilent"),c.acquireTokenSilent(i).catch(async e=>{if(e instanceof r.InteractionRequiredAuthError){if(f.current)throw s.error("useMsalAuthentication - Interaction required but is already in progress. Please try again, if needed, after interaction completes."),I.createUnableToFallbackToInteractionError();return s.error("useMsalAuthentication - Interaction required, falling back to interaction"),S(a,i)}throw e})))().then(e=>(A.current&&h([e,null]),e)).catch(e=>{throw A.current&&h([null,e]),e})},[c,e,n,s,u,S]);return t.useEffect(()=>{const e=c.addEventCallback(e=>{switch(e.eventType){case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:e.payload&&h([e.payload,null]);break;case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:e.error&&h([null,e.error])}});return s.verbose("useMsalAuthentication - Registered event callback with id: "+e),()=>{e&&(s.verbose("useMsalAuthentication - Removing event callback "+e),c.removeEventCallback(e))}},[c,s]),t.useEffect(()=>{E.current&&a===r.InteractionStatus.None&&(E.current=!1,i?u&&(s.info("useMsalAuthentication - User is authenticated, attempting to acquire token"),v().catch(()=>{})):(s.info("useMsalAuthentication - No user is authenticated, attempting to login"),S().catch(()=>{})))},[i,u,a,S,v,s]),{login:S,acquireToken:v,result:l,error:g}}exports.AuthenticatedTemplate=function(e){let{username:o,homeAccountId:c,localAccountId:s,children:i}=e;const u=d();return p(t.useMemo(()=>({username:o,homeAccountId:c,localAccountId:s}),[o,c,s]))&&u.inProgress!==r.InteractionStatus.Startup?n.createElement(n.Fragment,null,a(i,u)):null},exports.MsalAuthenticationTemplate=function(e){let{interactionType:o,username:c,homeAccountId:s,localAccountId:i,authenticationRequest:u,loadingComponent:l,errorComponent:g,children:h}=e;const m=t.useMemo(()=>({username:c,homeAccountId:s,localAccountId:i}),[c,s,i]),I=d(),f=A(o,u,m),E=p(m);if(f.error&&I.inProgress===r.InteractionStatus.None){if(g)return n.createElement(g,Object.assign({},f));throw f.error}return E?n.createElement(n.Fragment,null,a(h,f)):l&&I.inProgress!==r.InteractionStatus.None?n.createElement(l,Object.assign({},I)):null},exports.MsalConsumer=c,exports.MsalContext=o,exports.MsalProvider=function(e){let{instance:c,children:a}=e;t.useEffect(()=>{c.initializeWrapperLibrary(r.WrapperSKU.React,"1.5.2")},[c]);const s=t.useMemo(()=>c.getLogger().clone("@azure/msal-react","1.5.2"),[c]),[i,d]=t.useReducer(l,void 0,()=>({inProgress:r.InteractionStatus.Startup,accounts:c.getAllAccounts()}));return t.useEffect(()=>{const e=c.addEventCallback(e=>{d({payload:{instance:c,logger:s,message:e},type:u.EVENT})});return s.verbose("MsalProvider - Registered event callback with id: "+e),c.initialize().then(()=>{c.handleRedirectPromise().catch(()=>{}).finally(()=>{d({payload:{instance:c,logger:s},type:u.UNBLOCK_INPROGRESS})})}),()=>{e&&(s.verbose("MsalProvider - Removing event callback "+e),c.removeEventCallback(e))}},[c,s]),n.createElement(o.Provider,{value:{instance:c,inProgress:i.inProgress,accounts:i.accounts,logger:s}},a)},exports.UnauthenticatedTemplate=function(e){let{username:o,homeAccountId:c,localAccountId:s,children:i}=e;const u=d();return p(t.useMemo(()=>({username:o,homeAccountId:c,localAccountId:s}),[o,c,s]))||u.inProgress===r.InteractionStatus.Startup||u.inProgress===r.InteractionStatus.HandleRedirect?null:n.createElement(n.Fragment,null,a(i,u))},exports.useAccount=m,exports.useIsAuthenticated=p,exports.useMsal=d,exports.useMsalAuthentication=A,exports.version="1.5.2",exports.withMsal=e=>{const t=t=>{const r=d();return n.createElement(e,Object.assign({},t,{msalContext:r}))};return t.displayName=`withMsal(${e.displayName||e.name||"Component"})`,t};
//# sourceMappingURL=msal-react.cjs.production.min.js.map

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

const name = "@azure/msal-react";
const version = "1.5.1";
const version = "1.5.2";

@@ -84,0 +84,0 @@ /*

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

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

"build:modules:watch": "tsdx watch --verbose --tsconfig ./tsconfig.build.json",
"test": "tsdx test .*.spec.*",
"test": "tsdx test .*MsalAuthenticationTemplate.spec.*",
"test:watch": "tsdx test .*.spec.* --watch",

@@ -45,3 +45,3 @@ "test:coverage": "tsdx test .*.spec.* --coverage",

"peerDependencies": {
"@azure/msal-browser": "^2.32.1",
"@azure/msal-browser": "^2.32.2",
"react": "^16.8.0 || ^17 || ^18"

@@ -51,3 +51,3 @@ },

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

@@ -54,0 +54,0 @@ "@testing-library/react": "^13.4.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

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