@nibssplc/cams-sdk-react 1.0.0-rc.22 → 1.0.0-rc.23
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/hooks/useCAMSMSALAuth.d.ts +0 -2
- package/dist/index.cjs.js +11 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -13
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,7 +11,6 @@ export interface UseCAMSMSALAuthOptions {
|
|
|
11
11
|
appCode: string;
|
|
12
12
|
allowedOrigins?: string[];
|
|
13
13
|
MFAEndpoint?: string;
|
|
14
|
-
activeCookiePeriod?: number;
|
|
15
14
|
}
|
|
16
15
|
export interface UseCAMSMSALAuthReturn {
|
|
17
16
|
login: () => Promise<void>;
|
|
@@ -28,6 +27,5 @@ export interface UseCAMSMSALAuthReturn {
|
|
|
28
27
|
completeMFA: (data: UserValidatedResponse) => Promise<MFAResponse>;
|
|
29
28
|
setRequiresMFA: React.Dispatch<React.SetStateAction<boolean>>;
|
|
30
29
|
sendEmailOTP: () => Promise<boolean>;
|
|
31
|
-
activeCookiePeriod: number;
|
|
32
30
|
}
|
|
33
31
|
export declare function useCAMSMSALAuth(options: UseCAMSMSALAuthOptions): UseCAMSMSALAuthReturn;
|
package/dist/index.cjs.js
CHANGED
|
@@ -383,7 +383,6 @@ function useCAMSAuth(options) {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
var setCookie = function (name, value, days) {
|
|
386
|
-
if (days === void 0) { days = 1; }
|
|
387
386
|
var expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
|
|
388
387
|
console.log("Auth Cookie Expires >>>", { name: name, value: value, expires: expires });
|
|
389
388
|
document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; expires=").concat(expires, "; path=/; samesite=Lax");
|
|
@@ -405,15 +404,15 @@ var deleteCookie = function (name) {
|
|
|
405
404
|
|
|
406
405
|
function useCAMSMSALAuth(options) {
|
|
407
406
|
var _this = this;
|
|
408
|
-
var optStorageKey = options.storageKey, optScopes = options.scopes, prompt = options.prompt, appCode = options.appCode, MFAEndpoint = options.MFAEndpoint, onAuthSuccess = options.onAuthSuccess, onAuthError = options.onAuthError
|
|
407
|
+
var optStorageKey = options.storageKey, optScopes = options.scopes, prompt = options.prompt, appCode = options.appCode, MFAEndpoint = options.MFAEndpoint, onAuthSuccess = options.onAuthSuccess, onAuthError = options.onAuthError;
|
|
409
408
|
var storageKey = optStorageKey || "CAMS-MSAL-AUTH-SDK";
|
|
410
|
-
var
|
|
409
|
+
var _a = msalReact.useMsal(), instance = _a.instance, inProgress = _a.inProgress, accounts = _a.accounts;
|
|
411
410
|
var account = msalReact.useAccount(accounts[0] || {});
|
|
412
|
-
var
|
|
413
|
-
var
|
|
414
|
-
var
|
|
415
|
-
var
|
|
416
|
-
var
|
|
411
|
+
var _b = React.useState(null), error = _b[0], setError = _b[1];
|
|
412
|
+
var _c = React.useState(""), idToken = _c[0], setIdToken = _c[1];
|
|
413
|
+
var _d = React.useState(""), accessToken = _d[0], setAccessToken = _d[1];
|
|
414
|
+
var _e = React.useState(null), mfaAuthenticator = _e[0], setMfaAuthenticator = _e[1];
|
|
415
|
+
var _f = React.useState(false), requiresMFA = _f[0], setRequiresMFA = _f[1];
|
|
417
416
|
var isLoading = inProgress !== msalBrowser.InteractionStatus.None;
|
|
418
417
|
var isAuthenticated = !!account && !!accessToken && !requiresMFA;
|
|
419
418
|
var scopes = optScopes || ["openid", "profile", "email"];
|
|
@@ -580,7 +579,7 @@ function useCAMSMSALAuth(options) {
|
|
|
580
579
|
accessToken: accessToken,
|
|
581
580
|
idToken: idToken,
|
|
582
581
|
}));
|
|
583
|
-
setCookie("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }),
|
|
582
|
+
setCookie("CAMS-MSAL-AUTH-SDK-PROFILE", JSON.stringify({ type: "AUTH_SUCCESS", userProfile: __assign({}, data) }), 1);
|
|
584
583
|
setRequiresMFA(false);
|
|
585
584
|
// Set requiresMFA to false after storage update
|
|
586
585
|
camsSdk.Logger.debug("MFA completed successfully, storage updated", {
|
|
@@ -599,7 +598,7 @@ function useCAMSMSALAuth(options) {
|
|
|
599
598
|
}
|
|
600
599
|
return [2 /*return*/];
|
|
601
600
|
});
|
|
602
|
-
}); }, [mfaAuthenticator, accessToken, idToken, storageKey
|
|
601
|
+
}); }, [mfaAuthenticator, accessToken, idToken, storageKey]);
|
|
603
602
|
var sendEmailOTP = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
604
603
|
return __generator$1(this, function (_a) {
|
|
605
604
|
switch (_a.label) {
|
|
@@ -655,8 +654,7 @@ function useCAMSMSALAuth(options) {
|
|
|
655
654
|
requiresMFA: requiresMFA,
|
|
656
655
|
completeMFA: completeMFA,
|
|
657
656
|
sendEmailOTP: sendEmailOTP,
|
|
658
|
-
setRequiresMFA: setRequiresMFA
|
|
659
|
-
activeCookiePeriod: activeCookiePeriod,
|
|
657
|
+
setRequiresMFA: setRequiresMFA
|
|
660
658
|
};
|
|
661
659
|
}
|
|
662
660
|
|
|
@@ -1463,7 +1461,7 @@ function UnifiedCAMSProvider(props) {
|
|
|
1463
1461
|
// Validate appCode is a valid GUID
|
|
1464
1462
|
var appCodeValidation = GuidSchema.safeParse(props.appCode);
|
|
1465
1463
|
if (!appCodeValidation.success) {
|
|
1466
|
-
throw new Error("Invalid
|
|
1464
|
+
throw new Error("Invalid CAS APP CODE: ".concat(appCodeValidation.error.issues[0].message));
|
|
1467
1465
|
}
|
|
1468
1466
|
if (props.mode === "MSAL") {
|
|
1469
1467
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|