@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 +14 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +14 -11
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -21,10 +21,8 @@ import axios from 'axios';
|
|
|
21
21
|
import https from 'https';
|
|
22
22
|
|
|
23
23
|
// Crypto polyfill for MSAL browser compatibility
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
if (typeof window === "undefined")
|
|
27
|
-
return;
|
|
24
|
+
if (typeof window !== "undefined") {
|
|
25
|
+
// Run immediately and synchronously
|
|
28
26
|
// Ensure crypto object exists
|
|
29
27
|
if (!window.crypto) {
|
|
30
28
|
window.crypto = {};
|
|
@@ -39,7 +37,7 @@ import https from 'https';
|
|
|
39
37
|
return array;
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
|
-
var
|
|
40
|
+
var sha256_1 = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
41
|
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;
|
|
44
42
|
return __generator(this, function (_a) {
|
|
45
43
|
toUint8 = function (src) {
|
|
@@ -133,19 +131,19 @@ import https from 'https';
|
|
|
133
131
|
});
|
|
134
132
|
}); };
|
|
135
133
|
// Store reference to original subtle if it exists
|
|
136
|
-
var
|
|
134
|
+
var originalSubtle_1 = window.crypto.subtle;
|
|
137
135
|
// Create the polyfilled subtle object
|
|
138
136
|
var polyfillSubtle = {
|
|
139
|
-
digest: function (algorithm, data) { return __awaiter(
|
|
137
|
+
digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
138
|
var alg;
|
|
141
139
|
return __generator(this, function (_a) {
|
|
142
140
|
alg = typeof algorithm === "string"
|
|
143
141
|
? algorithm
|
|
144
142
|
: algorithm.name;
|
|
145
143
|
if (alg === "SHA-256")
|
|
146
|
-
return [2 /*return*/,
|
|
147
|
-
if (
|
|
148
|
-
return [2 /*return*/,
|
|
144
|
+
return [2 /*return*/, sha256_1(data)];
|
|
145
|
+
if (originalSubtle_1 === null || originalSubtle_1 === void 0 ? void 0 : originalSubtle_1.digest)
|
|
146
|
+
return [2 /*return*/, originalSubtle_1.digest(algorithm, data)];
|
|
149
147
|
throw new Error("Unsupported algorithm: ".concat(alg));
|
|
150
148
|
});
|
|
151
149
|
}); },
|
|
@@ -176,7 +174,7 @@ import https from 'https';
|
|
|
176
174
|
}
|
|
177
175
|
// Log success for debugging
|
|
178
176
|
console.log("Crypto polyfill loaded successfully");
|
|
179
|
-
}
|
|
177
|
+
}
|
|
180
178
|
|
|
181
179
|
/******************************************************************************
|
|
182
180
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1356,7 +1354,12 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1356
1354
|
return (jsxRuntimeExports.jsx(CAMSMSALContext.Provider, { value: value, children: children }));
|
|
1357
1355
|
}
|
|
1358
1356
|
function CAMSMSALProvider(props) {
|
|
1357
|
+
var _a;
|
|
1359
1358
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|
|
1359
|
+
// Ensure crypto is available before creating MSAL instance
|
|
1360
|
+
if (typeof window !== "undefined" && !((_a = window.crypto) === null || _a === void 0 ? void 0 : _a.subtle)) {
|
|
1361
|
+
throw new Error("Crypto API not available. Polyfill failed to load.");
|
|
1362
|
+
}
|
|
1360
1363
|
var instance = msalInstance || new PublicClientApplication(msalConfig);
|
|
1361
1364
|
return (jsxRuntimeExports.jsx(MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSMSALProviderInner, __assign({}, props)) }));
|
|
1362
1365
|
}
|