s3db.js 3.2.1 → 3.2.3

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/s3db.cjs.js CHANGED
@@ -746,7 +746,7 @@ class NoSuchBucket extends BaseError {
746
746
  }
747
747
  class NoSuchKey extends BaseError {
748
748
  constructor({ bucket, key, ...rest }) {
749
- super({ ...rest, bucket, message: `Key does not exists [bucket:${bucket}/${key}]` });
749
+ super({ ...rest, bucket, message: `Key [${key}] does not exists [bucket:${bucket}/${key}]` });
750
750
  this.key = key;
751
751
  }
752
752
  }
@@ -1185,11 +1185,19 @@ class Client extends EventEmitter {
1185
1185
  }
1186
1186
 
1187
1187
  async function dynamicCrypto() {
1188
- if (lodashEs.isObject(process)) {
1189
- return (await Promise.resolve().then(function () { return _polyfillNode_crypto; })).webcrypto;
1190
- } else {
1191
- return window.crypto;
1188
+ let lib;
1189
+ if (process) {
1190
+ try {
1191
+ const { webcrypto } = await import('crypto');
1192
+ lib = webcrypto;
1193
+ } catch (error) {
1194
+ throw new Error("Crypto API not available");
1195
+ }
1196
+ } else if (window) {
1197
+ lib = window.crypto;
1192
1198
  }
1199
+ if (!lib) throw new Error("Could not load any crypto library");
1200
+ return lib;
1193
1201
  }
1194
1202
  async function sha256(message) {
1195
1203
  const cryptoLib = await dynamicCrypto();
@@ -13178,10 +13186,6 @@ class CachePlugin extends Plugin {
13178
13186
  }
13179
13187
  }
13180
13188
 
13181
- var _polyfillNode_crypto = /*#__PURE__*/Object.freeze({
13182
- __proto__: null
13183
- });
13184
-
13185
13189
  exports.BaseError = BaseError;
13186
13190
  exports.Cache = Cache;
13187
13191
  exports.CachePlugin = CachePlugin;