@azure/msal-react
Advanced tools
Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6
@@ -5,2 +5,17 @@ { | ||
{ | ||
"date": "Thu, 18 Feb 2021 00:34:32 GMT", | ||
"tag": "@azure/msal-react_v1.0.0-alpha.6", | ||
"version": "1.0.0-alpha.6", | ||
"comments": { | ||
"none": [ | ||
{ | ||
"comment": "review changes, add reference to class-components doc", | ||
"author": "dogan.erisen@gmail.com", | ||
"commit": "92cbfdbc4680084a9ca45684cf0732f3fc305f1e", | ||
"package": "@azure/msal-react" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 09 Feb 2021 01:48:22 GMT", | ||
@@ -7,0 +22,0 @@ "tag": "@azure/msal-react_v1.0.0-alpha.5", |
@@ -66,3 +66,3 @@ 'use strict'; | ||
var name = "@azure/msal-react"; | ||
var version = "1.0.0-alpha.5"; | ||
var version = "1.0.0-alpha.6"; | ||
@@ -69,0 +69,0 @@ /* |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),n=(t=e)&&"object"==typeof t&&"default"in t?t.default:t,r=require("@azure/msal-browser"),o=e.createContext({instance:r.stubbedPublicClientApplication,inProgress:r.InteractionStatus.None,accounts:[],logger:new r.Logger({})}),a=o.Consumer;function i(t,e){return"function"==typeof t?t(e):t}var c=function(){return e.useContext(o)};function u(t,e){var n=t.getAllAccounts();return n.length>0&&(e.homeAccountId||e.localAccountId||e.username)&&n.filter((function(t){return!(e.username&&e.username.toLowerCase()!==t.username.toLowerCase()||e.homeAccountId&&e.homeAccountId.toLowerCase()!==t.homeAccountId.toLowerCase()||e.localAccountId&&e.localAccountId.toLowerCase()!==t.localAccountId.toLowerCase())}))[0]||null}function s(t){var n=c(),o=n.instance,a=n.inProgress,i=a===r.InteractionStatus.Startup?null:u(o,t),s=e.useState(i),l=s[0],f=s[1];return e.useEffect((function(){f(u(o,t))}),[a,t,o]),l}function l(t,e,n){return n&&(n.username||n.homeAccountId||n.localAccountId)?!!e:t.length>0}function f(t){var n=c(),o=n.accounts,a=n.inProgress,i=s(t||{}),u=a!==r.InteractionStatus.Startup&&l(o,i,t),f=e.useState(u),h=f[0],p=f[1];return e.useEffect((function(){p(l(o,i,t))}),[o,i,t]),h}function h(t,e,n,r,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}var p,v=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function u(t,e,n,r){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),a=new b(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw a;return{value:void 0,done:!0}}for(n.method=o,n.arg=a;;){var i=n.delegate;if(i){var c=w(i,n);if(c){if(c===l)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=s(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,a),o}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var v={};v[o]=function(){return this};var d=Object.getPrototypeOf,m=d&&d(d(A([])));m&&m!==e&&n.call(m,o)&&(v=m);var g=p.prototype=f.prototype=Object.create(v);function y(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){var r;this._invoke=function(o,a){function i(){return new e((function(r,i){!function r(o,a,i,c){var u=s(t[o],t,a);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){l.value=t,i(l)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}(o,a,r,i)}))}return r=r?r.then(i,i):i()}}function w(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,l;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function A(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,a=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return h.prototype=g.constructor=p,p.constructor=h,h.displayName=c(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,i,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},y(E.prototype),E.prototype[a]=function(){return this},t.AsyncIterator=E,t.async=function(e,n,r,o,a){void 0===a&&(a=Promise);var i=new E(u(e,n,r,o),a);return t.isGeneratorFunction(n)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},y(g),c(g,i,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=A,b.prototype={constructor:b,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return i.type="throw",i.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:A(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(p={exports:{}}),p.exports);function d(t,n,o){var a=c(),i=a.instance,u=a.inProgress,s=a.logger,l=f(o),p=e.useState([null,null]),d=p[0],m=d[0],g=d[1],y=p[1],E=e.useState(!1),w=E[0],I=E[1],S=e.useCallback(function(){var e,o=(e=v.mark((function e(o,a){var c;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c=a||n,e.t0=o||t,e.next=e.t0===r.InteractionType.Popup?5:e.t0===r.InteractionType.Redirect?7:e.t0===r.InteractionType.Silent?9:11;break;case 5:return s.verbose("useMsalAuthentication - Calling loginPopup"),e.abrupt("return",i.loginPopup(c));case 7:return s.verbose("useMsalAuthentication - Calling loginRedirect"),e.abrupt("return",i.loginRedirect(c).then(null));case 9:return s.verbose("useMsalAuthentication - Calling ssoSilent"),e.abrupt("return",i.ssoSilent(c));case 11:throw"Invalid interaction type provided.";case 12:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(t){h(a,r,o,i,c,"next",t)}function c(t){h(a,r,o,i,c,"throw",t)}i(void 0)}))});return function(t,e){return o.apply(this,arguments)}}(),[i,t,n,s]);return e.useEffect((function(){var t=i.addEventCallback((function(t){switch(t.eventType){case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:t.payload&&y([t.payload,null]);break;case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:t.error&&y([null,t.error])}}));return s.verbose("useMsalAuthentication - Registered event callback with id: "+t),function(){t&&(s.verbose("useMsalAuthentication - Removing event callback "+t),i.removeEventCallback(t))}}),[i,s]),e.useEffect((function(){w||g||l||u!==r.InteractionStatus.None||(s.info("useMsalAuthentication - No user is authenticated, attempting to login"),I(!0),S().catch((function(){})))}),[l,u,g,w,S,s]),{login:S,result:m,error:g}}Object.defineProperty(exports,"InteractionStatus",{enumerable:!0,get:function(){return r.InteractionStatus}}),exports.AuthenticatedTemplate=function(t){var o=t.username,a=t.homeAccountId,u=t.localAccountId,s=t.children,l=c();return f(e.useMemo((function(){return{username:o,homeAccountId:a,localAccountId:u}}),[o,a,u]))&&l.inProgress!==r.InteractionStatus.Startup?n.createElement(n.Fragment,null,i(s,l)):null},exports.MsalAuthenticationTemplate=function(t){var o=t.interactionType,a=t.username,u=t.homeAccountId,s=t.localAccountId,l=t.authenticationRequest,h=t.loadingComponent,p=t.errorComponent,v=t.children,m=e.useMemo((function(){return{username:a,homeAccountId:u,localAccountId:s}}),[a,u,s]),g=c(),y=d(o,l,m),E=f(m);if(y.error&&g.inProgress===r.InteractionStatus.None){if(p)return n.createElement(p,Object.assign({},y));throw y.error}return E?n.createElement(n.Fragment,null,i(v,y)):h&&g.inProgress!==r.InteractionStatus.None?n.createElement(h,Object.assign({},g)):null},exports.MsalConsumer=a,exports.MsalContext=o,exports.MsalProvider=function(t){var a=t.instance,i=t.children;e.useEffect((function(){a.initializeWrapperLibrary(r.WrapperSKU.React,"1.0.0-alpha.5")}),[a]);var c=e.useMemo((function(){return a.getLogger().clone("@azure/msal-react","1.0.0-alpha.5")}),[a]),u=e.useState([]),s=u[0],l=u[1],f=e.useState(r.InteractionStatus.Startup),h=f[0],p=f[1];return e.useEffect((function(){var t=a.addEventCallback((function(t){switch(t.eventType){case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:case r.EventType.HANDLE_REDIRECT_END:case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:case r.EventType.LOGOUT_FAILURE:case r.EventType.ACQUIRE_TOKEN_SUCCESS:case r.EventType.ACQUIRE_TOKEN_FAILURE:var e=a.getAllAccounts();!function(t,e){if(t.length!==e.length)return!1;var n=[].concat(e);return t.every((function(t){var e=n.shift();return!(!t||!e)&&t.homeAccountId===e.homeAccountId&&t.localAccountId===e.localAccountId&&t.username===e.username}))}(e,s)?(c.info("MsalProvider - updating account state"),l(e)):c.info("MsalProvider - no account changes")}}));return c.verbose("MsalProvider - Registered event callback with id: "+t),function(){t&&(c.verbose("MsalProvider - Removing event callback "+t),a.removeEventCallback(t))}}),[a,s,c]),e.useEffect((function(){var t=a.addEventCallback((function(t){var e=r.EventMessageUtils.getInteractionStatusFromEvent(t);null!==e&&(c.info("MsalProvider - "+t.eventType+" results in setting inProgress to "+e),p(e))}));return c.verbose("MsalProvider - Registered event callback with id: "+t),a.handleRedirectPromise().catch((function(){})),function(){t&&(c.verbose("MsalProvider - Removing event callback "+t),a.removeEventCallback(t))}}),[a,c]),n.createElement(o.Provider,{value:{instance:a,inProgress:h,accounts:s,logger:c}},i)},exports.UnauthenticatedTemplate=function(t){var o=t.username,a=t.homeAccountId,u=t.localAccountId,s=t.children,l=c();return f(e.useMemo((function(){return{username:o,homeAccountId:a,localAccountId:u}}),[o,a,u]))||l.inProgress===r.InteractionStatus.Startup?null:n.createElement(n.Fragment,null,i(s,l))},exports.useAccount=s,exports.useIsAuthenticated=f,exports.useMsal=c,exports.useMsalAuthentication=d,exports.withMsal=function(t){var e=function(e){var r=c();return n.createElement(t,Object.assign({},e,{msalContext:r}))};return e.displayName="withMsal("+(t.displayName||t.name||"Component")+")",e}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),n=(t=e)&&"object"==typeof t&&"default"in t?t.default:t,r=require("@azure/msal-browser"),o=e.createContext({instance:r.stubbedPublicClientApplication,inProgress:r.InteractionStatus.None,accounts:[],logger:new r.Logger({})}),a=o.Consumer;function i(t,e){return"function"==typeof t?t(e):t}var c=function(){return e.useContext(o)};function u(t,e){var n=t.getAllAccounts();return n.length>0&&(e.homeAccountId||e.localAccountId||e.username)&&n.filter((function(t){return!(e.username&&e.username.toLowerCase()!==t.username.toLowerCase()||e.homeAccountId&&e.homeAccountId.toLowerCase()!==t.homeAccountId.toLowerCase()||e.localAccountId&&e.localAccountId.toLowerCase()!==t.localAccountId.toLowerCase())}))[0]||null}function s(t){var n=c(),o=n.instance,a=n.inProgress,i=a===r.InteractionStatus.Startup?null:u(o,t),s=e.useState(i),l=s[0],f=s[1];return e.useEffect((function(){f(u(o,t))}),[a,t,o]),l}function l(t,e,n){return n&&(n.username||n.homeAccountId||n.localAccountId)?!!e:t.length>0}function f(t){var n=c(),o=n.accounts,a=n.inProgress,i=s(t||{}),u=a!==r.InteractionStatus.Startup&&l(o,i,t),f=e.useState(u),h=f[0],p=f[1];return e.useEffect((function(){p(l(o,i,t))}),[o,i,t]),h}function h(t,e,n,r,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}var p,v=(function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function u(t,e,n,r){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),a=new b(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw a;return{value:void 0,done:!0}}for(n.method=o,n.arg=a;;){var i=n.delegate;if(i){var c=w(i,n);if(c){if(c===l)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=s(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,a),o}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var v={};v[o]=function(){return this};var d=Object.getPrototypeOf,m=d&&d(d(A([])));m&&m!==e&&n.call(m,o)&&(v=m);var g=p.prototype=f.prototype=Object.create(v);function y(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){var r;this._invoke=function(o,a){function i(){return new e((function(r,i){!function r(o,a,i,c){var u=s(t[o],t,a);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){l.value=t,i(l)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}(o,a,r,i)}))}return r=r?r.then(i,i):i()}}function w(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,l;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function A(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,a=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return h.prototype=g.constructor=p,p.constructor=h,h.displayName=c(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,i,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},y(E.prototype),E.prototype[a]=function(){return this},t.AsyncIterator=E,t.async=function(e,n,r,o,a){void 0===a&&(a=Promise);var i=new E(u(e,n,r,o),a);return t.isGeneratorFunction(n)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},y(g),c(g,i,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=A,b.prototype={constructor:b,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return i.type="throw",i.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:A(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(p={exports:{}}),p.exports);function d(t,n,o){var a=c(),i=a.instance,u=a.inProgress,s=a.logger,l=f(o),p=e.useState([null,null]),d=p[0],m=d[0],g=d[1],y=p[1],E=e.useState(!1),w=E[0],I=E[1],S=e.useCallback(function(){var e,o=(e=v.mark((function e(o,a){var c;return v.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c=a||n,e.t0=o||t,e.next=e.t0===r.InteractionType.Popup?5:e.t0===r.InteractionType.Redirect?7:e.t0===r.InteractionType.Silent?9:11;break;case 5:return s.verbose("useMsalAuthentication - Calling loginPopup"),e.abrupt("return",i.loginPopup(c));case 7:return s.verbose("useMsalAuthentication - Calling loginRedirect"),e.abrupt("return",i.loginRedirect(c).then(null));case 9:return s.verbose("useMsalAuthentication - Calling ssoSilent"),e.abrupt("return",i.ssoSilent(c));case 11:throw"Invalid interaction type provided.";case 12:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(t){h(a,r,o,i,c,"next",t)}function c(t){h(a,r,o,i,c,"throw",t)}i(void 0)}))});return function(t,e){return o.apply(this,arguments)}}(),[i,t,n,s]);return e.useEffect((function(){var t=i.addEventCallback((function(t){switch(t.eventType){case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:t.payload&&y([t.payload,null]);break;case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:t.error&&y([null,t.error])}}));return s.verbose("useMsalAuthentication - Registered event callback with id: "+t),function(){t&&(s.verbose("useMsalAuthentication - Removing event callback "+t),i.removeEventCallback(t))}}),[i,s]),e.useEffect((function(){w||g||l||u!==r.InteractionStatus.None||(s.info("useMsalAuthentication - No user is authenticated, attempting to login"),I(!0),S().catch((function(){})))}),[l,u,g,w,S,s]),{login:S,result:m,error:g}}Object.defineProperty(exports,"InteractionStatus",{enumerable:!0,get:function(){return r.InteractionStatus}}),exports.AuthenticatedTemplate=function(t){var o=t.username,a=t.homeAccountId,u=t.localAccountId,s=t.children,l=c();return f(e.useMemo((function(){return{username:o,homeAccountId:a,localAccountId:u}}),[o,a,u]))&&l.inProgress!==r.InteractionStatus.Startup?n.createElement(n.Fragment,null,i(s,l)):null},exports.MsalAuthenticationTemplate=function(t){var o=t.interactionType,a=t.username,u=t.homeAccountId,s=t.localAccountId,l=t.authenticationRequest,h=t.loadingComponent,p=t.errorComponent,v=t.children,m=e.useMemo((function(){return{username:a,homeAccountId:u,localAccountId:s}}),[a,u,s]),g=c(),y=d(o,l,m),E=f(m);if(y.error&&g.inProgress===r.InteractionStatus.None){if(p)return n.createElement(p,Object.assign({},y));throw y.error}return E?n.createElement(n.Fragment,null,i(v,y)):h&&g.inProgress!==r.InteractionStatus.None?n.createElement(h,Object.assign({},g)):null},exports.MsalConsumer=a,exports.MsalContext=o,exports.MsalProvider=function(t){var a=t.instance,i=t.children;e.useEffect((function(){a.initializeWrapperLibrary(r.WrapperSKU.React,"1.0.0-alpha.6")}),[a]);var c=e.useMemo((function(){return a.getLogger().clone("@azure/msal-react","1.0.0-alpha.6")}),[a]),u=e.useState([]),s=u[0],l=u[1],f=e.useState(r.InteractionStatus.Startup),h=f[0],p=f[1];return e.useEffect((function(){var t=a.addEventCallback((function(t){switch(t.eventType){case r.EventType.LOGIN_SUCCESS:case r.EventType.SSO_SILENT_SUCCESS:case r.EventType.HANDLE_REDIRECT_END:case r.EventType.LOGIN_FAILURE:case r.EventType.SSO_SILENT_FAILURE:case r.EventType.LOGOUT_FAILURE:case r.EventType.ACQUIRE_TOKEN_SUCCESS:case r.EventType.ACQUIRE_TOKEN_FAILURE:var e=a.getAllAccounts();!function(t,e){if(t.length!==e.length)return!1;var n=[].concat(e);return t.every((function(t){var e=n.shift();return!(!t||!e)&&t.homeAccountId===e.homeAccountId&&t.localAccountId===e.localAccountId&&t.username===e.username}))}(e,s)?(c.info("MsalProvider - updating account state"),l(e)):c.info("MsalProvider - no account changes")}}));return c.verbose("MsalProvider - Registered event callback with id: "+t),function(){t&&(c.verbose("MsalProvider - Removing event callback "+t),a.removeEventCallback(t))}}),[a,s,c]),e.useEffect((function(){var t=a.addEventCallback((function(t){var e=r.EventMessageUtils.getInteractionStatusFromEvent(t);null!==e&&(c.info("MsalProvider - "+t.eventType+" results in setting inProgress to "+e),p(e))}));return c.verbose("MsalProvider - Registered event callback with id: "+t),a.handleRedirectPromise().catch((function(){})),function(){t&&(c.verbose("MsalProvider - Removing event callback "+t),a.removeEventCallback(t))}}),[a,c]),n.createElement(o.Provider,{value:{instance:a,inProgress:h,accounts:s,logger:c}},i)},exports.UnauthenticatedTemplate=function(t){var o=t.username,a=t.homeAccountId,u=t.localAccountId,s=t.children,l=c();return f(e.useMemo((function(){return{username:o,homeAccountId:a,localAccountId:u}}),[o,a,u]))||l.inProgress===r.InteractionStatus.Startup?null:n.createElement(n.Fragment,null,i(s,l))},exports.useAccount=s,exports.useIsAuthenticated=f,exports.useMsal=c,exports.useMsalAuthentication=d,exports.withMsal=function(t){var e=function(e){var r=c();return n.createElement(t,Object.assign({},e,{msalContext:r}))};return e.displayName="withMsal("+(t.displayName||t.name||"Component")+")",e}; | ||
//# sourceMappingURL=msal-react.cjs.production.min.js.map |
@@ -60,3 +60,3 @@ import React__default, { createContext, useEffect, useMemo, useState, useContext, useCallback } from 'react'; | ||
var name = "@azure/msal-react"; | ||
var version = "1.0.0-alpha.5"; | ||
var version = "1.0.0-alpha.6"; | ||
@@ -63,0 +63,0 @@ /* |
export declare const name = "@azure/msal-react"; | ||
export declare const version = "1.0.0-alpha.5"; | ||
export declare const version = "1.0.0-alpha.6"; |
{ | ||
"name": "@azure/msal-react", | ||
"version": "1.0.0-alpha.5", | ||
"version": "1.0.0-alpha.6", | ||
"author": { | ||
@@ -40,3 +40,3 @@ "name": "Microsoft", | ||
"peerDependencies": { | ||
"@azure/msal-browser": "^2.11.1", | ||
"@azure/msal-browser": "^2.11.2", | ||
"react": "^16.13.0 || ^17" | ||
@@ -46,3 +46,3 @@ }, | ||
"devDependencies": { | ||
"@azure/msal-browser": "^2.11.1", | ||
"@azure/msal-browser": "^2.11.2", | ||
"@babel/core": "^7.12.10", | ||
@@ -49,0 +49,0 @@ "@storybook/addon-actions": "^6.1.10", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
354098
2679