@nibssplc/cams-sdk-react 1.0.0-rc.11 → 1.0.0-rc.12

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.esm.js CHANGED
@@ -20,25 +20,51 @@ import { motion } from 'framer-motion';
20
20
  import axios from 'axios';
21
21
  import https from 'https';
22
22
 
23
- var _a;
24
- // Crypto polyfill for environments where crypto is not available
25
- if (typeof window !== 'undefined' && !window.crypto) {
26
- var crypto_1 = require('crypto');
27
- // @ts-ignore
28
- window.crypto = {
29
- getRandomValues: function (arr) {
30
- var bytes = crypto_1.randomBytes(arr.length);
31
- for (var i = 0; i < arr.length; i++) {
32
- arr[i] = bytes[i];
23
+ // Crypto polyfill for MSAL browser compatibility
24
+ if (typeof window !== 'undefined') {
25
+ // Ensure crypto object exists
26
+ if (!window.crypto) {
27
+ window.crypto = {};
28
+ }
29
+ // Polyfill getRandomValues with better entropy
30
+ if (!window.crypto.getRandomValues) {
31
+ window.crypto.getRandomValues = function (array) {
32
+ var bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
33
+ for (var i = 0; i < bytes.length; i++) {
34
+ bytes[i] = Math.floor((Math.random() * 256 +
35
+ (performance.now() % 256) +
36
+ (Date.now() % 256)) / 3) & 0xFF;
33
37
  }
34
- return arr;
35
- },
36
- subtle: ((_a = crypto_1.webcrypto) === null || _a === void 0 ? void 0 : _a.subtle) || {
37
- digest: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
38
- throw new Error('crypto.subtle not available');
39
- }); }); }
40
- }
41
- };
38
+ return array;
39
+ };
40
+ }
41
+ // Polyfill crypto.subtle
42
+ if (!window.crypto.subtle) {
43
+ window.crypto.subtle = {
44
+ digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
45
+ var bytes, hash, i;
46
+ return __generator(this, function (_a) {
47
+ bytes = new Uint8Array(data);
48
+ hash = 0;
49
+ for (i = 0; i < bytes.length; i++) {
50
+ hash = ((hash << 5) - hash) + bytes[i];
51
+ hash = hash & hash;
52
+ }
53
+ return [2 /*return*/, new Uint8Array([hash]).buffer];
54
+ });
55
+ }); }
56
+ };
57
+ }
58
+ // Polyfill randomUUID
59
+ if (!window.crypto.randomUUID) {
60
+ window.crypto.randomUUID = function () {
61
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
62
+ var r = (Math.random() * 16) | 0;
63
+ var v = c === 'x' ? r : (r & 0x3) | 0x8;
64
+ return v.toString(16);
65
+ });
66
+ };
67
+ }
42
68
  }
43
69
 
44
70
  /******************************************************************************