@nibssplc/cams-sdk-react 1.0.0-rc.24 → 1.0.0-rc.25

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
@@ -45,20 +45,38 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPri
45
45
  if (typeof window !== 'undefined') {
46
46
  // Ensure crypto object exists
47
47
  if (!window.crypto) {
48
- window.crypto = {};
48
+ try {
49
+ Object.defineProperty(window, 'crypto', {
50
+ value: {},
51
+ writable: true,
52
+ configurable: true
53
+ });
54
+ }
55
+ catch (e) {
56
+ // Ignore if crypto cannot be defined
57
+ }
49
58
  }
50
59
  // Polyfill getRandomValues
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
- }
57
- return array;
58
- };
60
+ if (window.crypto && !window.crypto.getRandomValues) {
61
+ try {
62
+ Object.defineProperty(window.crypto, 'getRandomValues', {
63
+ value: function (array) {
64
+ var bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
65
+ for (var i = 0; i < bytes.length; i++) {
66
+ bytes[i] = Math.floor(Math.random() * 256);
67
+ }
68
+ return array;
69
+ },
70
+ writable: true,
71
+ configurable: true
72
+ });
73
+ }
74
+ catch (e) {
75
+ // Ignore if getRandomValues cannot be defined
76
+ }
59
77
  }
60
78
  // Polyfill crypto.subtle with SHA-256 (handles both undefined and null in non-HTTPS contexts)
61
- if (!window.crypto.subtle || window.location.protocol === 'http:') {
79
+ if (window.crypto && (!window.crypto.subtle || window.location.protocol === 'http:')) {
62
80
  var sha256_1 = function (data) { return __awaiter(void 0, void 0, void 0, function () {
63
81
  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
82
  return __generator(this, function (_a) {
@@ -128,28 +146,46 @@ if (typeof window !== 'undefined') {
128
146
  return [2 /*return*/, result.buffer];
129
147
  });
130
148
  }); };
131
- window.crypto.subtle = {
132
- digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
133
- var alg;
134
- return __generator(this, function (_a) {
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));
140
- });
141
- }); }
142
- };
149
+ try {
150
+ Object.defineProperty(window.crypto, 'subtle', {
151
+ value: {
152
+ digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
153
+ var alg;
154
+ return __generator(this, function (_a) {
155
+ alg = typeof algorithm === 'string' ? algorithm : algorithm.name;
156
+ if (alg === 'SHA-256')
157
+ return [2 /*return*/, sha256_1(data)];
158
+ console.error("Unsupported crypto algorithm: ".concat(alg));
159
+ throw new Error("Unsupported algorithm: ".concat(alg));
160
+ });
161
+ }); }
162
+ },
163
+ writable: true,
164
+ configurable: true
165
+ });
166
+ }
167
+ catch (e) {
168
+ // Ignore if subtle cannot be defined
169
+ }
143
170
  }
144
171
  // Polyfill randomUUID
145
- if (!window.crypto.randomUUID) {
146
- window.crypto.randomUUID = function () {
147
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
148
- var r = (Math.random() * 16) | 0;
149
- var v = c === 'x' ? r : (r & 0x3) | 0x8;
150
- return v.toString(16);
172
+ if (window.crypto && !window.crypto.randomUUID) {
173
+ try {
174
+ Object.defineProperty(window.crypto, 'randomUUID', {
175
+ value: function () {
176
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
177
+ var r = (Math.random() * 16) | 0;
178
+ var v = c === 'x' ? r : (r & 0x3) | 0x8;
179
+ return v.toString(16);
180
+ });
181
+ },
182
+ writable: true,
183
+ configurable: true
151
184
  });
152
- };
185
+ }
186
+ catch (e) {
187
+ // Ignore if randomUUID cannot be defined
188
+ }
153
189
  }
154
190
  }
155
191