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