lean-s3 0.9.2 → 0.9.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.
Files changed (2) hide show
  1. package/dist/index.mjs +9 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -320,7 +320,7 @@ const kSignedRequest = Symbol("kSignedRequest");
320
320
  const kGetEffectiveParams = Symbol("kGetEffectiveParams");
321
321
  const xmlParser = new XMLParser({
322
322
  ignoreAttributes: true,
323
- isArray: (_, jPath) => jPath === "ListMultipartUploadsResult.Upload" || jPath === "ListBucketResult.Contents" || jPath === "ListPartsResult.Part" || jPath === "DeleteResult.Deleted" || jPath === "DeleteResult.Error"
323
+ isArray: (_, jPath) => jPath === "ListMultipartUploadsResult.Upload" || jPath === "ListBucketResult.Contents" || jPath === "ListPartsResult.Part" || jPath === "DeleteResult.Deleted" || jPath === "DeleteResult.Error" || jPath === "CORSConfiguration.CORSRule" || jPath === "CORSConfiguration.CORSRule.AllowedMethod" || jPath === "CORSConfiguration.CORSRule.AllowedOrigin" || jPath === "CORSConfiguration.CORSRule.AllowedHeader" || jPath === "CORSConfiguration.CORSRule.ExposeHeader"
324
324
  });
325
325
  const xmlBuilder = new XMLBuilder({
326
326
  attributeNamePrefix: "$",
@@ -802,7 +802,14 @@ var S3Client = class {
802
802
  response.body.dump();
803
803
  throw fromStatusCode(response.statusCode, "");
804
804
  }
805
- throw new Error("Not implemented");
805
+ return { rules: ((ensureParsedXml(await response.body.text()).CORSConfiguration ?? {}).CORSRule ?? []).filter(Boolean).map((r) => ({
806
+ allowedMethods: r.AllowedMethod ?? [],
807
+ allowedOrigins: r.AllowedOrigin ?? [],
808
+ allowedHeaders: r.AllowedHeader ? r.AllowedHeader : void 0,
809
+ exposeHeaders: r.ExposeHeader ? r.ExposeHeader : void 0,
810
+ id: r.ID ?? void 0,
811
+ maxAgeSeconds: typeof r.MaxAgeSeconds !== "undefined" && r.MaxAgeSeconds !== null ? Number(r.MaxAgeSeconds) : void 0
812
+ })) };
806
813
  }
807
814
  /**
808
815
  * @remarks Uses [`DeleteBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketCors.html).
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lean-s3",
3
3
  "author": "Niklas Mollenhauer",
4
4
  "license": "MIT",
5
- "version": "0.9.2",
5
+ "version": "0.9.3",
6
6
  "description": "A server-side S3 API for the regular user.",
7
7
  "keywords": [
8
8
  "s3",