@nibssplc/cams-sdk-react 1.0.0-rc.12 → 1.0.0-rc.14
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 +85 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +85 -16
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -47,31 +47,96 @@ if (typeof window !== 'undefined') {
|
|
|
47
47
|
if (!window.crypto) {
|
|
48
48
|
window.crypto = {};
|
|
49
49
|
}
|
|
50
|
-
// Polyfill getRandomValues
|
|
50
|
+
// Polyfill getRandomValues
|
|
51
51
|
if (!window.crypto.getRandomValues) {
|
|
52
52
|
window.crypto.getRandomValues = function (array) {
|
|
53
53
|
var bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
54
54
|
for (var i = 0; i < bytes.length; i++) {
|
|
55
|
-
bytes[i] = Math.floor(
|
|
56
|
-
(performance.now() % 256) +
|
|
57
|
-
(Date.now() % 256)) / 3) & 0xFF;
|
|
55
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
58
56
|
}
|
|
59
57
|
return array;
|
|
60
58
|
};
|
|
61
59
|
}
|
|
62
|
-
// Polyfill crypto.subtle
|
|
60
|
+
// Polyfill crypto.subtle with SHA-256
|
|
63
61
|
if (!window.crypto.subtle) {
|
|
62
|
+
var sha256_1 = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
+
var bytes, hash, k, ml, msg, i, w, j, j, s0, s1, a, b, c, d, e, f, g, h, j, S1, ch, temp1, S0, maj, temp2, result, i;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
bytes = new Uint8Array(data);
|
|
66
|
+
hash = new Uint32Array(8);
|
|
67
|
+
k = new Uint32Array([
|
|
68
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
69
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
70
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
71
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
72
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
73
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
74
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
75
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
76
|
+
]);
|
|
77
|
+
hash[0] = 0x6a09e667;
|
|
78
|
+
hash[1] = 0xbb67ae85;
|
|
79
|
+
hash[2] = 0x3c6ef372;
|
|
80
|
+
hash[3] = 0xa54ff53a;
|
|
81
|
+
hash[4] = 0x510e527f;
|
|
82
|
+
hash[5] = 0x9b05688c;
|
|
83
|
+
hash[6] = 0x1f83d9ab;
|
|
84
|
+
hash[7] = 0x5be0cd19;
|
|
85
|
+
ml = bytes.length * 8;
|
|
86
|
+
msg = new Uint8Array(bytes.length + 64 + ((64 - ((bytes.length + 9) % 64)) % 64));
|
|
87
|
+
msg.set(bytes);
|
|
88
|
+
msg[bytes.length] = 0x80;
|
|
89
|
+
new DataView(msg.buffer).setUint32(msg.length - 4, ml, false);
|
|
90
|
+
for (i = 0; i < msg.length; i += 64) {
|
|
91
|
+
w = new Uint32Array(64);
|
|
92
|
+
for (j = 0; j < 16; j++)
|
|
93
|
+
w[j] = new DataView(msg.buffer).getUint32(i + j * 4, false);
|
|
94
|
+
for (j = 16; j < 64; j++) {
|
|
95
|
+
s0 = ((w[j - 15] >>> 7) | (w[j - 15] << 25)) ^ ((w[j - 15] >>> 18) | (w[j - 15] << 14)) ^ (w[j - 15] >>> 3);
|
|
96
|
+
s1 = ((w[j - 2] >>> 17) | (w[j - 2] << 15)) ^ ((w[j - 2] >>> 19) | (w[j - 2] << 13)) ^ (w[j - 2] >>> 10);
|
|
97
|
+
w[j] = (w[j - 16] + s0 + w[j - 7] + s1) >>> 0;
|
|
98
|
+
}
|
|
99
|
+
a = hash[0], b = hash[1], c = hash[2], d = hash[3], e = hash[4], f = hash[5], g = hash[6], h = hash[7];
|
|
100
|
+
for (j = 0; j < 64; j++) {
|
|
101
|
+
S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
|
|
102
|
+
ch = (e & f) ^ (~e & g);
|
|
103
|
+
temp1 = (h + S1 + ch + k[j] + w[j]) >>> 0;
|
|
104
|
+
S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
|
|
105
|
+
maj = (a & b) ^ (a & c) ^ (b & c);
|
|
106
|
+
temp2 = (S0 + maj) >>> 0;
|
|
107
|
+
h = g;
|
|
108
|
+
g = f;
|
|
109
|
+
f = e;
|
|
110
|
+
e = (d + temp1) >>> 0;
|
|
111
|
+
d = c;
|
|
112
|
+
c = b;
|
|
113
|
+
b = a;
|
|
114
|
+
a = (temp1 + temp2) >>> 0;
|
|
115
|
+
}
|
|
116
|
+
hash[0] = (hash[0] + a) >>> 0;
|
|
117
|
+
hash[1] = (hash[1] + b) >>> 0;
|
|
118
|
+
hash[2] = (hash[2] + c) >>> 0;
|
|
119
|
+
hash[3] = (hash[3] + d) >>> 0;
|
|
120
|
+
hash[4] = (hash[4] + e) >>> 0;
|
|
121
|
+
hash[5] = (hash[5] + f) >>> 0;
|
|
122
|
+
hash[6] = (hash[6] + g) >>> 0;
|
|
123
|
+
hash[7] = (hash[7] + h) >>> 0;
|
|
124
|
+
}
|
|
125
|
+
result = new Uint8Array(32);
|
|
126
|
+
for (i = 0; i < 8; i++)
|
|
127
|
+
new DataView(result.buffer).setUint32(i * 4, hash[i], false);
|
|
128
|
+
return [2 /*return*/, result.buffer];
|
|
129
|
+
});
|
|
130
|
+
}); };
|
|
64
131
|
window.crypto.subtle = {
|
|
65
132
|
digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
-
var
|
|
133
|
+
var alg;
|
|
67
134
|
return __generator(this, function (_a) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
return [2 /*return*/, new Uint8Array([hash]).buffer];
|
|
135
|
+
alg = typeof algorithm === 'string' ? algorithm : algorithm.name;
|
|
136
|
+
if (alg === 'SHA-256')
|
|
137
|
+
return [2 /*return*/, sha256_1(data)];
|
|
138
|
+
console.error("Unsupported crypto algorithm: ".concat(alg));
|
|
139
|
+
throw new Error("Unsupported algorithm: ".concat(alg));
|
|
75
140
|
});
|
|
76
141
|
}); }
|
|
77
142
|
};
|
|
@@ -1237,7 +1302,7 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1237
1302
|
localStorage.setItem(auth.storageKey, JSON.stringify({
|
|
1238
1303
|
accessToken: auth.accessToken,
|
|
1239
1304
|
idToken: auth.idToken,
|
|
1240
|
-
appCode: auth.appCode
|
|
1305
|
+
appCode: auth.appCode,
|
|
1241
1306
|
}));
|
|
1242
1307
|
}
|
|
1243
1308
|
}, [auth.accessToken, auth.idToken, auth.storageKey]);
|
|
@@ -1272,7 +1337,9 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1272
1337
|
}
|
|
1273
1338
|
function CAMSMSALProvider(props) {
|
|
1274
1339
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|
|
1275
|
-
var instance =
|
|
1340
|
+
var instance = typeof window !== "undefined"
|
|
1341
|
+
? msalInstance || new msalBrowser.PublicClientApplication(msalConfig)
|
|
1342
|
+
: null;
|
|
1276
1343
|
return (jsxRuntimeExports.jsx(msalReact.MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSMSALProviderInner, __assign({}, props)) }));
|
|
1277
1344
|
}
|
|
1278
1345
|
function useCAMSMSALContext() {
|
|
@@ -1406,7 +1473,9 @@ function UnifiedCAMSProvider(props) {
|
|
|
1406
1473
|
}
|
|
1407
1474
|
if (props.mode === "MSAL") {
|
|
1408
1475
|
var msalConfig = props.msalConfig, msalInstance = props.msalInstance;
|
|
1409
|
-
var instance =
|
|
1476
|
+
var instance = typeof window !== "undefined"
|
|
1477
|
+
? msalInstance || new msalBrowser.PublicClientApplication(msalConfig)
|
|
1478
|
+
: null;
|
|
1410
1479
|
return (jsxRuntimeExports.jsx(msalReact.MsalProvider, { instance: instance, children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));
|
|
1411
1480
|
}
|
|
1412
1481
|
return (jsxRuntimeExports.jsx(ClientOnly, { fallback: jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: jsxRuntimeExports.jsx(CAMSProviderCore, __assign({}, props)) }));
|