@nibssplc/cams-sdk-react 0.0.1-beta.28 → 0.0.1-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { CAMSConfig } from '@nibssplc/cams-sdk';
|
|
3
3
|
import { UseCAMSAuthReturn, UseCAMSAuthOptions } from '../hooks/useCAMSAuth';
|
|
4
|
+
import { UseCAMSMSALAuthOptions } from '../hooks/useCAMSMSALAuth';
|
|
4
5
|
interface CAMSContextValue extends UseCAMSAuthReturn {
|
|
5
6
|
defaultConfig?: Partial<CAMSConfig>;
|
|
7
|
+
isAuthenticated: boolean;
|
|
8
|
+
idToken: string | null;
|
|
9
|
+
accessToken: string | null;
|
|
6
10
|
}
|
|
7
11
|
export interface CAMSProviderProps extends UseCAMSAuthOptions {
|
|
8
12
|
children: ReactNode;
|
|
9
13
|
defaultConfig?: Partial<CAMSConfig>;
|
|
14
|
+
msalOptions?: UseCAMSMSALAuthOptions;
|
|
10
15
|
}
|
|
11
|
-
export declare function CAMSProvider({ children, defaultConfig, ...authOptions }: CAMSProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function CAMSProvider({ children, defaultConfig, msalOptions, ...authOptions }: CAMSProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
17
|
export declare function useCAMSContext(): CAMSContextValue;
|
|
13
18
|
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -16726,10 +16726,10 @@ function useCAMSMSALAuth(options) {
|
|
|
16726
16726
|
if (account && !isMFAPending) {
|
|
16727
16727
|
// Get token in foreground popup
|
|
16728
16728
|
instance
|
|
16729
|
-
.
|
|
16729
|
+
.acquireTokenPopup({
|
|
16730
16730
|
scopes: scopes,
|
|
16731
16731
|
account: account,
|
|
16732
|
-
prompt: options.prompt || "
|
|
16732
|
+
prompt: options.prompt || "login",
|
|
16733
16733
|
})
|
|
16734
16734
|
.then(function (response) {
|
|
16735
16735
|
var _a;
|
|
@@ -16762,7 +16762,7 @@ function useCAMSMSALAuth(options) {
|
|
|
16762
16762
|
_d.trys.push([1, 3, , 8]);
|
|
16763
16763
|
return [4 /*yield*/, instance.loginPopup({
|
|
16764
16764
|
scopes: scopes,
|
|
16765
|
-
prompt: options.prompt || "
|
|
16765
|
+
prompt: options.prompt || "login",
|
|
16766
16766
|
})];
|
|
16767
16767
|
case 2:
|
|
16768
16768
|
_d.sent();
|
|
@@ -16776,7 +16776,7 @@ function useCAMSMSALAuth(options) {
|
|
|
16776
16776
|
_d.trys.push([4, 6, , 7]);
|
|
16777
16777
|
return [4 /*yield*/, instance.loginRedirect({
|
|
16778
16778
|
scopes: scopes,
|
|
16779
|
-
prompt: options.prompt || "
|
|
16779
|
+
prompt: options.prompt || "login",
|
|
16780
16780
|
})];
|
|
16781
16781
|
case 5:
|
|
16782
16782
|
_d.sent();
|
|
@@ -17252,13 +17252,14 @@ var jsxRuntimeExports = jsxRuntime.exports;
|
|
|
17252
17252
|
|
|
17253
17253
|
var CAMSContext = React__default.createContext(null);
|
|
17254
17254
|
function CAMSProvider(_a) {
|
|
17255
|
-
var children = _a.children, defaultConfig = _a.defaultConfig, authOptions = __rest(_a, ["children", "defaultConfig"]);
|
|
17255
|
+
var children = _a.children, defaultConfig = _a.defaultConfig, msalOptions = _a.msalOptions, authOptions = __rest(_a, ["children", "defaultConfig", "msalOptions"]);
|
|
17256
17256
|
var _b = React__default.useState(false), mounted = _b[0], setMounted = _b[1];
|
|
17257
17257
|
var auth = useCAMSAuth(authOptions);
|
|
17258
|
+
var msalAuth = useCAMSMSALAuth(msalOptions || { mfaUrl: '/auth/multi-factor' });
|
|
17258
17259
|
React__default.useEffect(function () {
|
|
17259
17260
|
setMounted(true);
|
|
17260
17261
|
}, []);
|
|
17261
|
-
var value = React__default.useMemo(function () { return (__assign(__assign({}, auth), { defaultConfig: defaultConfig })); }, [auth, defaultConfig]);
|
|
17262
|
+
var value = React__default.useMemo(function () { return (__assign(__assign({}, auth), { defaultConfig: defaultConfig, isAuthenticated: msalAuth.isAuthenticated, idToken: msalAuth.idToken, accessToken: msalAuth.accessToken })); }, [auth, defaultConfig, msalAuth.isAuthenticated, msalAuth.idToken, msalAuth.accessToken]);
|
|
17262
17263
|
if (!mounted) {
|
|
17263
17264
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
17264
17265
|
}
|