s3db.js 7.4.0 → 7.4.1

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
@@ -9654,7 +9654,13 @@ class Client extends EventEmitter {
9654
9654
  if (metadata) {
9655
9655
  for (const [k, v] of Object.entries(metadata)) {
9656
9656
  const validKey = String(k).replace(/[^a-zA-Z0-9\-_]/g, "_");
9657
- stringMetadata[validKey] = String(v);
9657
+ const stringValue = String(v);
9658
+ const hasSpecialChars = /[^\x00-\x7F]/.test(stringValue);
9659
+ if (hasSpecialChars) {
9660
+ stringMetadata[validKey] = Buffer.from(stringValue, "utf8").toString("base64");
9661
+ } else {
9662
+ stringMetadata[validKey] = stringValue;
9663
+ }
9658
9664
  }
9659
9665
  }
9660
9666
  const options = {
@@ -9691,6 +9697,28 @@ class Client extends EventEmitter {
9691
9697
  let response, error;
9692
9698
  try {
9693
9699
  response = await this.sendCommand(new clientS3.GetObjectCommand(options));
9700
+ if (response.Metadata) {
9701
+ const decodedMetadata = {};
9702
+ for (const [key2, value] of Object.entries(response.Metadata)) {
9703
+ if (typeof value === "string") {
9704
+ try {
9705
+ const decoded = Buffer.from(value, "base64").toString("utf8");
9706
+ const hasSpecialChars = /[^\x00-\x7F]/.test(decoded);
9707
+ const isValidBase64 = Buffer.from(decoded, "utf8").toString("base64") === value;
9708
+ if (isValidBase64 && hasSpecialChars && decoded !== value) {
9709
+ decodedMetadata[key2] = decoded;
9710
+ } else {
9711
+ decodedMetadata[key2] = value;
9712
+ }
9713
+ } catch (decodeError) {
9714
+ decodedMetadata[key2] = value;
9715
+ }
9716
+ } else {
9717
+ decodedMetadata[key2] = value;
9718
+ }
9719
+ }
9720
+ response.Metadata = decodedMetadata;
9721
+ }
9694
9722
  return response;
9695
9723
  } catch (err) {
9696
9724
  error = err;
@@ -13281,7 +13309,7 @@ class Database extends EventEmitter {
13281
13309
  super();
13282
13310
  this.version = "1";
13283
13311
  this.s3dbVersion = (() => {
13284
- const [ok, err, version] = try_fn_default(() => true ? "7.3.10" : "latest");
13312
+ const [ok, err, version] = try_fn_default(() => true ? "7.4.1" : "latest");
13285
13313
  return ok ? version : "latest";
13286
13314
  })();
13287
13315
  this.resources = {};