@nibssplc/cams-sdk-react 1.0.0-rc.24 → 1.0.0-rc.26
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 +65 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +65 -29
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -24,20 +24,38 @@ import https from 'https';
|
|
|
24
24
|
if (typeof window !== 'undefined') {
|
|
25
25
|
// Ensure crypto object exists
|
|
26
26
|
if (!window.crypto) {
|
|
27
|
-
|
|
27
|
+
try {
|
|
28
|
+
Object.defineProperty(window, 'crypto', {
|
|
29
|
+
value: {},
|
|
30
|
+
writable: true,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
// Ignore if crypto cannot be defined
|
|
36
|
+
}
|
|
28
37
|
}
|
|
29
38
|
// Polyfill getRandomValues
|
|
30
|
-
if (!window.crypto.getRandomValues) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
if (window.crypto && !window.crypto.getRandomValues) {
|
|
40
|
+
try {
|
|
41
|
+
Object.defineProperty(window.crypto, 'getRandomValues', {
|
|
42
|
+
value: function (array) {
|
|
43
|
+
var bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
44
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
45
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
46
|
+
}
|
|
47
|
+
return array;
|
|
48
|
+
},
|
|
49
|
+
writable: true,
|
|
50
|
+
configurable: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
// Ignore if getRandomValues cannot be defined
|
|
55
|
+
}
|
|
38
56
|
}
|
|
39
57
|
// Polyfill crypto.subtle with SHA-256 (handles both undefined and null in non-HTTPS contexts)
|
|
40
|
-
if (
|
|
58
|
+
if (window.crypto && (!window.crypto.subtle)) {
|
|
41
59
|
var sha256_1 = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
60
|
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
61
|
return __generator(this, function (_a) {
|
|
@@ -107,28 +125,46 @@ if (typeof window !== 'undefined') {
|
|
|
107
125
|
return [2 /*return*/, result.buffer];
|
|
108
126
|
});
|
|
109
127
|
}); };
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
try {
|
|
129
|
+
Object.defineProperty(window.crypto, 'subtle', {
|
|
130
|
+
value: {
|
|
131
|
+
digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
|
+
var alg;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
alg = typeof algorithm === 'string' ? algorithm : algorithm.name;
|
|
135
|
+
if (alg === 'SHA-256')
|
|
136
|
+
return [2 /*return*/, sha256_1(data)];
|
|
137
|
+
console.error("Unsupported crypto algorithm: ".concat(alg));
|
|
138
|
+
throw new Error("Unsupported algorithm: ".concat(alg));
|
|
139
|
+
});
|
|
140
|
+
}); }
|
|
141
|
+
},
|
|
142
|
+
writable: true,
|
|
143
|
+
configurable: true
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
// Ignore if subtle cannot be defined
|
|
148
|
+
}
|
|
122
149
|
}
|
|
123
150
|
// Polyfill randomUUID
|
|
124
|
-
if (!window.crypto.randomUUID) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
151
|
+
if (window.crypto && !window.crypto.randomUUID) {
|
|
152
|
+
try {
|
|
153
|
+
Object.defineProperty(window.crypto, 'randomUUID', {
|
|
154
|
+
value: function () {
|
|
155
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
156
|
+
var r = (Math.random() * 16) | 0;
|
|
157
|
+
var v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
158
|
+
return v.toString(16);
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
writable: true,
|
|
162
|
+
configurable: true
|
|
130
163
|
});
|
|
131
|
-
}
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
// Ignore if randomUUID cannot be defined
|
|
167
|
+
}
|
|
132
168
|
}
|
|
133
169
|
}
|
|
134
170
|
|