@nibssplc/cams-sdk-react 0.0.1-beta.80 → 0.0.1-beta.83
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.
- package/dist/index.cjs.js +0 -55
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.esm.js +2 -56
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/hooks/useCAMSPopupAuth.d.ts +0 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './hooks/useCAMSAuth';
|
|
2
2
|
export * from './hooks/useCAMSMSALAuth';
|
|
3
|
-
export * from './hooks/useCAMSPopupAuth';
|
|
4
3
|
export * from './components/ProtectedRoute';
|
|
5
4
|
export { CAMSMSALProvider, useCAMSMSALContext } from './components/CAMSMSALProvider';
|
|
6
5
|
export * from './components/ClientOnly';
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { useState, useRef, useEffect, useCallback, createContext, useContext, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { CAMSSessionManager, isPopupWindow, CAMSMFAAuthenticator, Logger, CAMSError, CAMSErrorType } from '@nibssplc/cams-sdk';
|
|
4
4
|
export * from '@nibssplc/cams-sdk';
|
|
5
5
|
import { useMsal, useAccount, MsalProvider } from '@azure/msal-react';
|
|
6
6
|
import { InteractionStatus, PublicClientApplication } from '@azure/msal-browser';
|
|
@@ -131,10 +131,6 @@ function useCAMSAuth(options) {
|
|
|
131
131
|
// Only initialize on client side
|
|
132
132
|
if (typeof window === "undefined")
|
|
133
133
|
return;
|
|
134
|
-
// Initialize popup auth handler if in popup
|
|
135
|
-
if (isPopupWindow()) {
|
|
136
|
-
initializePopupAuth();
|
|
137
|
-
}
|
|
138
134
|
(_a = sessionManagerRef.current) !== null && _a !== void 0 ? _a : (sessionManagerRef.current = new CAMSSessionManager(localStorage, options.storageKey || "CAMS-AUTH-SDK", {
|
|
139
135
|
onAuthSuccess: function (res) {
|
|
140
136
|
var _a;
|
|
@@ -517,56 +513,6 @@ function useCAMSMSALAuth(options) {
|
|
|
517
513
|
};
|
|
518
514
|
}
|
|
519
515
|
|
|
520
|
-
/**
|
|
521
|
-
* Hook for handling authentication in popup windows
|
|
522
|
-
* This should be used by the popup app to complete authentication
|
|
523
|
-
*/
|
|
524
|
-
function useCAMSPopupAuth(options) {
|
|
525
|
-
if (options === void 0) { options = {}; }
|
|
526
|
-
var _a = options.storageKey, storageKey = _a === void 0 ? "CAMS-SDK" : _a, targetOrigin = options.targetOrigin, onAuthComplete = options.onAuthComplete, onAuthError = options.onAuthError;
|
|
527
|
-
useEffect(function () {
|
|
528
|
-
if (typeof window === "undefined" || !isPopupWindow())
|
|
529
|
-
return;
|
|
530
|
-
// Initialize popup auth handler
|
|
531
|
-
initializePopupAuth(targetOrigin);
|
|
532
|
-
// Set up global handlers for the popup app
|
|
533
|
-
var globalHandlers = window.__CAMS_POPUP_AUTH__;
|
|
534
|
-
if (globalHandlers) {
|
|
535
|
-
var originalCompleteAuth_1 = globalHandlers.completeAuth;
|
|
536
|
-
var originalErrorAuth_1 = globalHandlers.errorAuth;
|
|
537
|
-
globalHandlers.completeAuth = function (profile) {
|
|
538
|
-
onAuthComplete === null || onAuthComplete === void 0 ? void 0 : onAuthComplete(profile);
|
|
539
|
-
originalCompleteAuth_1(profile);
|
|
540
|
-
};
|
|
541
|
-
globalHandlers.errorAuth = function (error) {
|
|
542
|
-
onAuthError === null || onAuthError === void 0 ? void 0 : onAuthError(error);
|
|
543
|
-
originalErrorAuth_1(error);
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
}, [targetOrigin, onAuthComplete, onAuthError]);
|
|
547
|
-
var completeAuth = useCallback(function (profile) {
|
|
548
|
-
if (!isPopupWindow()) {
|
|
549
|
-
console.warn("completeAuth called outside of popup window");
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
var sessionManager = new CAMSSessionManager(localStorage, storageKey);
|
|
553
|
-
sessionManager.completePopupAuth(profile, targetOrigin);
|
|
554
|
-
}, [storageKey, targetOrigin]);
|
|
555
|
-
var errorAuth = useCallback(function (error) {
|
|
556
|
-
if (!isPopupWindow()) {
|
|
557
|
-
console.warn("errorAuth called outside of popup window");
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
var sessionManager = new CAMSSessionManager(localStorage, storageKey);
|
|
561
|
-
sessionManager.errorPopupAuth(error, targetOrigin);
|
|
562
|
-
}, [storageKey, targetOrigin]);
|
|
563
|
-
return {
|
|
564
|
-
completeAuth: completeAuth,
|
|
565
|
-
errorAuth: errorAuth,
|
|
566
|
-
isPopup: isPopupWindow(),
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
|
|
570
516
|
var jsxRuntime = {exports: {}};
|
|
571
517
|
|
|
572
518
|
var reactJsxRuntime_production = {};
|
|
@@ -2024,5 +1970,5 @@ var MFAGate = function (_a) {
|
|
|
2024
1970
|
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
2025
1971
|
};
|
|
2026
1972
|
|
|
2027
|
-
export { CAMSMSALProvider, CAMSProvider, ClientOnly, DefaultLoginPage as LoginButton, MFAGate, MFAOptions, ProtectedRoute, UnifiedCAMSProvider, useCAMSAuth, useCAMSContext, useCAMSMSALAuth, useCAMSMSALContext
|
|
1973
|
+
export { CAMSMSALProvider, CAMSProvider, ClientOnly, DefaultLoginPage as LoginButton, MFAGate, MFAOptions, ProtectedRoute, UnifiedCAMSProvider, useCAMSAuth, useCAMSContext, useCAMSMSALAuth, useCAMSMSALContext };
|
|
2028
1974
|
//# sourceMappingURL=index.esm.js.map
|