@nibssplc/cams-sdk-react 1.0.0-rc.37 → 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.esm.js CHANGED
@@ -110,22 +110,46 @@ import https from 'https';
110
110
  }); };
111
111
  // Force override crypto.subtle
112
112
  var originalSubtle = window.crypto.subtle;
113
- window.crypto.subtle = {
114
- digest: function (algorithm, data) { return __awaiter(_this, void 0, void 0, function () {
115
- var alg;
116
- return __generator(this, function (_a) {
117
- alg = typeof algorithm === 'string' ? algorithm : algorithm.name;
118
- if (alg === 'SHA-256')
119
- return [2 /*return*/, sha256(data)];
120
- if (originalSubtle === null || originalSubtle === void 0 ? void 0 : originalSubtle.digest)
121
- return [2 /*return*/, originalSubtle.digest(algorithm, data)];
122
- throw new Error("Unsupported algorithm: ".concat(alg));
123
- });
124
- }); }
125
- };
113
+ try {
114
+ Object.defineProperty(window.crypto, 'subtle', {
115
+ configurable: true,
116
+ get: function () {
117
+ var _this = this;
118
+ return {
119
+ digest: function (algorithm, data) { return __awaiter(_this, void 0, void 0, function () {
120
+ var alg;
121
+ return __generator(this, function (_a) {
122
+ alg = typeof algorithm === 'string' ? algorithm : algorithm.name;
123
+ if (alg === 'SHA-256')
124
+ return [2 /*return*/, sha256(data)];
125
+ if (originalSubtle === null || originalSubtle === void 0 ? void 0 : originalSubtle.digest)
126
+ return [2 /*return*/, originalSubtle.digest(algorithm, data)];
127
+ throw new Error("Unsupported algorithm: ".concat(alg));
128
+ });
129
+ }); }
130
+ };
131
+ }
132
+ });
133
+ }
134
+ catch (_a) {
135
+ // Some environments prevent redefining built-ins; fallback to a typed assertion assignment
136
+ window.crypto.subtle = {
137
+ digest: function (algorithm, data) { return __awaiter(_this, void 0, void 0, function () {
138
+ var alg;
139
+ return __generator(this, function (_a) {
140
+ alg = typeof algorithm === 'string' ? algorithm : algorithm.name;
141
+ if (alg === 'SHA-256')
142
+ return [2 /*return*/, sha256(data)];
143
+ if (originalSubtle === null || originalSubtle === void 0 ? void 0 : originalSubtle.digest)
144
+ return [2 /*return*/, originalSubtle.digest(algorithm, data)];
145
+ throw new Error("Unsupported algorithm: ".concat(alg));
146
+ });
147
+ }); }
148
+ };
149
+ }
126
150
  // Polyfill randomUUID
127
- if (!window.crypto.randomUUID) {
128
- window.crypto.randomUUID = function () {
151
+ if (!globalThis.crypto.randomUUID) {
152
+ globalThis.crypto.randomUUID = function () {
129
153
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
130
154
  var r = (Math.random() * 16) | 0;
131
155
  var v = c === 'x' ? r : (r & 0x3) | 0x8;