@nibssplc/cams-sdk-react 1.0.0-rc.40 → 1.0.0-rc.41

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 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
- (function () {
46
- var _this = this;
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 sha256 = function (data) { return __awaiter(_this, void 0, void 0, function () {
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 originalSubtle = window.crypto.subtle;
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(_this, void 0, void 0, function () {
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*/, sha256(data)];
168
- if (originalSubtle === null || originalSubtle === void 0 ? void 0 : originalSubtle.digest)
169
- return [2 /*return*/, originalSubtle.digest(algorithm, data)];
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
  }