@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.cjs.js CHANGED
@@ -41,25 +41,51 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
41
41
  var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimitive);
42
42
  var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
43
43
 
44
- var _a;
45
- // Crypto polyfill for environments where crypto is not available
46
- if (typeof window !== 'undefined' && !window.crypto) {
47
- var crypto_1 = require('crypto');
48
- // @ts-ignore
49
- window.crypto = {
50
- getRandomValues: function (arr) {
51
- var bytes = crypto_1.randomBytes(arr.length);
52
- for (var i = 0; i < arr.length; i++) {
53
- arr[i] = bytes[i];
44
+ // Crypto polyfill for MSAL browser compatibility
45
+ if (typeof window !== 'undefined') {
46
+ // Ensure crypto object exists
47
+ if (!window.crypto) {
48
+ window.crypto = {};
49
+ }
50
+ // Polyfill getRandomValues with better entropy
51
+ if (!window.crypto.getRandomValues) {
52
+ window.crypto.getRandomValues = function (array) {
53
+ var bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
54
+ for (var i = 0; i < bytes.length; i++) {
55
+ bytes[i] = Math.floor((Math.random() * 256 +
56
+ (performance.now() % 256) +
57
+ (Date.now() % 256)) / 3) & 0xFF;
54
58
  }
55
- return arr;
56
- },
57
- subtle: ((_a = crypto_1.webcrypto) === null || _a === void 0 ? void 0 : _a.subtle) || {
58
- digest: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
59
- throw new Error('crypto.subtle not available');
60
- }); }); }
61
- }
62
- };
59
+ return array;
60
+ };
61
+ }
62
+ // Polyfill crypto.subtle
63
+ if (!window.crypto.subtle) {
64
+ window.crypto.subtle = {
65
+ digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
66
+ var bytes, hash, i;
67
+ return __generator(this, function (_a) {
68
+ bytes = new Uint8Array(data);
69
+ hash = 0;
70
+ for (i = 0; i < bytes.length; i++) {
71
+ hash = ((hash << 5) - hash) + bytes[i];
72
+ hash = hash & hash;
73
+ }
74
+ return [2 /*return*/, new Uint8Array([hash]).buffer];
75
+ });
76
+ }); }
77
+ };
78
+ }
79
+ // Polyfill randomUUID
80
+ if (!window.crypto.randomUUID) {
81
+ window.crypto.randomUUID = function () {
82
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
83
+ var r = (Math.random() * 16) | 0;
84
+ var v = c === 'x' ? r : (r & 0x3) | 0x8;
85
+ return v.toString(16);
86
+ });
87
+ };
88
+ }
63
89
  }
64
90
 
65
91
  /******************************************************************************