@nibssplc/cams-sdk-react 1.0.0-rc.13 → 1.0.0-rc.15
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 +79 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +79 -14
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -26,31 +26,96 @@ if (typeof window !== 'undefined') {
|
|
|
26
26
|
if (!window.crypto) {
|
|
27
27
|
window.crypto = {};
|
|
28
28
|
}
|
|
29
|
-
// Polyfill getRandomValues
|
|
29
|
+
// Polyfill getRandomValues
|
|
30
30
|
if (!window.crypto.getRandomValues) {
|
|
31
31
|
window.crypto.getRandomValues = function (array) {
|
|
32
32
|
var bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
33
33
|
for (var i = 0; i < bytes.length; i++) {
|
|
34
|
-
bytes[i] = Math.floor(
|
|
35
|
-
(performance.now() % 256) +
|
|
36
|
-
(Date.now() % 256)) / 3) & 0xFF;
|
|
34
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
37
35
|
}
|
|
38
36
|
return array;
|
|
39
37
|
};
|
|
40
38
|
}
|
|
41
|
-
// Polyfill crypto.subtle
|
|
42
|
-
if (!window.crypto.subtle) {
|
|
39
|
+
// Polyfill crypto.subtle with SHA-256 (handles both undefined and null in non-HTTPS contexts)
|
|
40
|
+
if (!window.crypto.subtle || window.location.protocol === 'http:') {
|
|
41
|
+
var sha256_1 = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
+
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;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
bytes = new Uint8Array(data);
|
|
45
|
+
hash = new Uint32Array(8);
|
|
46
|
+
k = new Uint32Array([
|
|
47
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
48
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
49
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
50
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
51
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
52
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
53
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
54
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
55
|
+
]);
|
|
56
|
+
hash[0] = 0x6a09e667;
|
|
57
|
+
hash[1] = 0xbb67ae85;
|
|
58
|
+
hash[2] = 0x3c6ef372;
|
|
59
|
+
hash[3] = 0xa54ff53a;
|
|
60
|
+
hash[4] = 0x510e527f;
|
|
61
|
+
hash[5] = 0x9b05688c;
|
|
62
|
+
hash[6] = 0x1f83d9ab;
|
|
63
|
+
hash[7] = 0x5be0cd19;
|
|
64
|
+
ml = bytes.length * 8;
|
|
65
|
+
msg = new Uint8Array(bytes.length + 64 + ((64 - ((bytes.length + 9) % 64)) % 64));
|
|
66
|
+
msg.set(bytes);
|
|
67
|
+
msg[bytes.length] = 0x80;
|
|
68
|
+
new DataView(msg.buffer).setUint32(msg.length - 4, ml, false);
|
|
69
|
+
for (i = 0; i < msg.length; i += 64) {
|
|
70
|
+
w = new Uint32Array(64);
|
|
71
|
+
for (j = 0; j < 16; j++)
|
|
72
|
+
w[j] = new DataView(msg.buffer).getUint32(i + j * 4, false);
|
|
73
|
+
for (j = 16; j < 64; j++) {
|
|
74
|
+
s0 = ((w[j - 15] >>> 7) | (w[j - 15] << 25)) ^ ((w[j - 15] >>> 18) | (w[j - 15] << 14)) ^ (w[j - 15] >>> 3);
|
|
75
|
+
s1 = ((w[j - 2] >>> 17) | (w[j - 2] << 15)) ^ ((w[j - 2] >>> 19) | (w[j - 2] << 13)) ^ (w[j - 2] >>> 10);
|
|
76
|
+
w[j] = (w[j - 16] + s0 + w[j - 7] + s1) >>> 0;
|
|
77
|
+
}
|
|
78
|
+
a = hash[0], b = hash[1], c = hash[2], d = hash[3], e = hash[4], f = hash[5], g = hash[6], h = hash[7];
|
|
79
|
+
for (j = 0; j < 64; j++) {
|
|
80
|
+
S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
|
|
81
|
+
ch = (e & f) ^ (~e & g);
|
|
82
|
+
temp1 = (h + S1 + ch + k[j] + w[j]) >>> 0;
|
|
83
|
+
S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
|
|
84
|
+
maj = (a & b) ^ (a & c) ^ (b & c);
|
|
85
|
+
temp2 = (S0 + maj) >>> 0;
|
|
86
|
+
h = g;
|
|
87
|
+
g = f;
|
|
88
|
+
f = e;
|
|
89
|
+
e = (d + temp1) >>> 0;
|
|
90
|
+
d = c;
|
|
91
|
+
c = b;
|
|
92
|
+
b = a;
|
|
93
|
+
a = (temp1 + temp2) >>> 0;
|
|
94
|
+
}
|
|
95
|
+
hash[0] = (hash[0] + a) >>> 0;
|
|
96
|
+
hash[1] = (hash[1] + b) >>> 0;
|
|
97
|
+
hash[2] = (hash[2] + c) >>> 0;
|
|
98
|
+
hash[3] = (hash[3] + d) >>> 0;
|
|
99
|
+
hash[4] = (hash[4] + e) >>> 0;
|
|
100
|
+
hash[5] = (hash[5] + f) >>> 0;
|
|
101
|
+
hash[6] = (hash[6] + g) >>> 0;
|
|
102
|
+
hash[7] = (hash[7] + h) >>> 0;
|
|
103
|
+
}
|
|
104
|
+
result = new Uint8Array(32);
|
|
105
|
+
for (i = 0; i < 8; i++)
|
|
106
|
+
new DataView(result.buffer).setUint32(i * 4, hash[i], false);
|
|
107
|
+
return [2 /*return*/, result.buffer];
|
|
108
|
+
});
|
|
109
|
+
}); };
|
|
43
110
|
window.crypto.subtle = {
|
|
44
111
|
digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var
|
|
112
|
+
var alg;
|
|
46
113
|
return __generator(this, function (_a) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
return [2 /*return*/, new Uint8Array([hash]).buffer];
|
|
114
|
+
alg = typeof algorithm === 'string' ? algorithm : algorithm.name;
|
|
115
|
+
if (alg === 'SHA-256')
|
|
116
|
+
return [2 /*return*/, sha256_1(data)];
|
|
117
|
+
console.error("Unsupported crypto algorithm: ".concat(alg));
|
|
118
|
+
throw new Error("Unsupported algorithm: ".concat(alg));
|
|
54
119
|
});
|
|
55
120
|
}); }
|
|
56
121
|
};
|