@nibssplc/cams-sdk-react 1.0.0-rc.40 → 1.0.0-rc.42
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 +19 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -18
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -42,10 +42,8 @@ var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimi
|
|
|
42
42
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
|
|
43
43
|
|
|
44
44
|
// Crypto polyfill for MSAL browser compatibility
|
|
45
|
-
(
|
|
46
|
-
|
|
47
|
-
if (typeof window === "undefined")
|
|
48
|
-
return;
|
|
45
|
+
if (typeof window !== "undefined") {
|
|
46
|
+
// Run immediately and synchronously
|
|
49
47
|
// Ensure crypto object exists
|
|
50
48
|
if (!window.crypto) {
|
|
51
49
|
window.crypto = {};
|
|
@@ -60,7 +58,7 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPri
|
|
|
60
58
|
return array;
|
|
61
59
|
};
|
|
62
60
|
}
|
|
63
|
-
var
|
|
61
|
+
var sha256_1 = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
62
|
var toUint8, bytes, hash, k, ml, msg, dv, high, low, i, w, j, j, s0, s1, a, b, c, d, e, f, g, h, j, S1, ch, temp1, S0, maj, temp2, result, i;
|
|
65
63
|
return __generator(this, function (_a) {
|
|
66
64
|
toUint8 = function (src) {
|
|
@@ -154,19 +152,19 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPri
|
|
|
154
152
|
});
|
|
155
153
|
}); };
|
|
156
154
|
// Store reference to original subtle if it exists
|
|
157
|
-
var
|
|
155
|
+
var originalSubtle_1 = window.crypto.subtle;
|
|
158
156
|
// Create the polyfilled subtle object
|
|
159
157
|
var polyfillSubtle = {
|
|
160
|
-
digest: function (algorithm, data) { return __awaiter(
|
|
158
|
+
digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
161
159
|
var alg;
|
|
162
160
|
return __generator(this, function (_a) {
|
|
163
161
|
alg = typeof algorithm === "string"
|
|
164
162
|
? algorithm
|
|
165
163
|
: algorithm.name;
|
|
166
164
|
if (alg === "SHA-256")
|
|
167
|
-
return [2 /*return*/,
|
|
168
|
-
if (
|
|
169
|
-
return [2 /*return*/,
|
|
165
|
+
return [2 /*return*/, sha256_1(data)];
|
|
166
|
+
if (originalSubtle_1 === null || originalSubtle_1 === void 0 ? void 0 : originalSubtle_1.digest)
|
|
167
|
+
return [2 /*return*/, originalSubtle_1.digest(algorithm, data)];
|
|
170
168
|
throw new Error("Unsupported algorithm: ".concat(alg));
|
|
171
169
|
});
|
|
172
170
|
}); },
|
|
@@ -197,7 +195,7 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPri
|
|
|
197
195
|
}
|
|
198
196
|
// Log success for debugging
|
|
199
197
|
console.log("Crypto polyfill loaded successfully");
|
|
200
|
-
}
|
|
198
|
+
}
|
|
201
199
|
|
|
202
200
|
/******************************************************************************
|
|
203
201
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1377,7 +1375,12 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1377
1375
|
return (jsxRuntimeExports.jsx(CAMSMSALContext.Provider, { value: value, children: children }));
|
|
1378
1376
|
}
|
|
1379
1377
|
function CAMSMSALProvider(props) {
|
|
1378
|
+
var _a;
|
|
1380
1379
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|
|
1380
|
+
// Ensure crypto is available before creating MSAL instance
|
|
1381
|
+
if (typeof window !== "undefined" && !((_a = window.crypto) === null || _a === void 0 ? void 0 : _a.subtle)) {
|
|
1382
|
+
throw new Error("Crypto API not available. Polyfill failed to load.");
|
|
1383
|
+
}
|
|
1381
1384
|
var instance = msalInstance || new msalBrowser.PublicClientApplication(msalConfig);
|
|
1382
1385
|
return (jsxRuntimeExports.jsx(msalReact.MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSMSALProviderInner, __assign({}, props)) }));
|
|
1383
1386
|
}
|
|
@@ -1470,26 +1473,20 @@ function CAMSProviderCore(props) {
|
|
|
1470
1473
|
}
|
|
1471
1474
|
});
|
|
1472
1475
|
}); };
|
|
1473
|
-
// Handle MFA completion for MSAL mode
|
|
1474
1476
|
React.useEffect(function () {
|
|
1475
1477
|
if (mode === "MSAL" &&
|
|
1476
1478
|
"requiresMFA" in auth &&
|
|
1477
1479
|
!auth.requiresMFA &&
|
|
1478
1480
|
auth.isAuthenticated) {
|
|
1479
|
-
// MFA completed, extract profile from localStorage
|
|
1480
1481
|
var storedData = localStorage.getItem(auth.storageKey);
|
|
1481
1482
|
if (storedData) {
|
|
1482
1483
|
try {
|
|
1483
1484
|
var parsed = JSON.parse(storedData);
|
|
1484
|
-
console.log("Parsed storage data:", parsed);
|
|
1485
1485
|
if (parsed.userProfile) {
|
|
1486
|
-
console.log("Setting user profile:", parsed.userProfile);
|
|
1487
1486
|
setUserProfile(parsed.userProfile);
|
|
1488
1487
|
}
|
|
1489
1488
|
}
|
|
1490
|
-
catch (
|
|
1491
|
-
console.error("Error parsing stored data:", e);
|
|
1492
|
-
}
|
|
1489
|
+
catch (_a) { }
|
|
1493
1490
|
}
|
|
1494
1491
|
}
|
|
1495
1492
|
}, [
|
|
@@ -1506,6 +1503,7 @@ function CAMSProviderCore(props) {
|
|
|
1506
1503
|
return jsxRuntimeExports.jsx(CAMSContext.Provider, { value: value, children: children });
|
|
1507
1504
|
}
|
|
1508
1505
|
function UnifiedCAMSProvider(props) {
|
|
1506
|
+
var _a;
|
|
1509
1507
|
// Validate appCode is a valid GUID
|
|
1510
1508
|
var appCodeValidation = GuidSchema.safeParse(props.appCode);
|
|
1511
1509
|
if (!appCodeValidation.success) {
|
|
@@ -1513,6 +1511,9 @@ function UnifiedCAMSProvider(props) {
|
|
|
1513
1511
|
}
|
|
1514
1512
|
if (props.mode === "MSAL") {
|
|
1515
1513
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|
|
1514
|
+
if (typeof window !== "undefined" && !((_a = window.crypto) === null || _a === void 0 ? void 0 : _a.subtle)) {
|
|
1515
|
+
throw new Error("Crypto API not available. Polyfill failed to load.");
|
|
1516
|
+
}
|
|
1516
1517
|
var instance = msalInstance || new msalBrowser.PublicClientApplication(msalConfig);
|
|
1517
1518
|
return (jsxRuntimeExports.jsx(msalReact.MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));
|
|
1518
1519
|
}
|