@nibssplc/cams-sdk-react 1.0.0-rc.36 → 1.0.0-rc.38

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
@@ -131,8 +131,30 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPri
131
131
  }); };
132
132
  // Force override crypto.subtle
133
133
  var originalSubtle = window.crypto.subtle;
134
- Object.defineProperty(window.crypto, 'subtle', {
135
- value: {
134
+ try {
135
+ Object.defineProperty(window.crypto, 'subtle', {
136
+ configurable: true,
137
+ get: function () {
138
+ var _this = this;
139
+ return {
140
+ digest: function (algorithm, data) { return __awaiter(_this, void 0, void 0, function () {
141
+ var alg;
142
+ return __generator(this, function (_a) {
143
+ alg = typeof algorithm === 'string' ? algorithm : algorithm.name;
144
+ if (alg === 'SHA-256')
145
+ return [2 /*return*/, sha256(data)];
146
+ if (originalSubtle === null || originalSubtle === void 0 ? void 0 : originalSubtle.digest)
147
+ return [2 /*return*/, originalSubtle.digest(algorithm, data)];
148
+ throw new Error("Unsupported algorithm: ".concat(alg));
149
+ });
150
+ }); }
151
+ };
152
+ }
153
+ });
154
+ }
155
+ catch (_a) {
156
+ // Some environments prevent redefining built-ins; fallback to a typed assertion assignment
157
+ window.crypto.subtle = {
136
158
  digest: function (algorithm, data) { return __awaiter(_this, void 0, void 0, function () {
137
159
  var alg;
138
160
  return __generator(this, function (_a) {
@@ -144,23 +166,17 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPri
144
166
  throw new Error("Unsupported algorithm: ".concat(alg));
145
167
  });
146
168
  }); }
147
- },
148
- writable: true,
149
- configurable: true
150
- });
169
+ };
170
+ }
151
171
  // Polyfill randomUUID
152
- if (!window.crypto.randomUUID) {
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
163
- });
172
+ if (!globalThis.crypto.randomUUID) {
173
+ globalThis.crypto.randomUUID = function () {
174
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
175
+ var r = (Math.random() * 16) | 0;
176
+ var v = c === 'x' ? r : (r & 0x3) | 0x8;
177
+ return v.toString(16);
178
+ });
179
+ };
164
180
  }
165
181
  })();
166
182