@stacksjs/ts-cloud 0.2.17 → 0.2.18

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.js CHANGED
@@ -2046,7 +2046,8 @@ class S3Client2 {
2046
2046
  const binaryBody = Buffer.isBuffer(normalizedBody) ? normalizedBody : Buffer.from(normalizedBody);
2047
2047
  const { accessKeyId, secretAccessKey, sessionToken } = this.getCredentials();
2048
2048
  const host = this.s3VirtualHost(options.bucket);
2049
- const url = `https://${host}/${options.key}`;
2049
+ const encodedKey = options.key.split("/").map((seg) => encodeURIComponent(seg)).join("/");
2050
+ const url = `https://${host}/${encodedKey}`;
2050
2051
  const now = new Date;
2051
2052
  const amzDate = now.toISOString().replace(/[:-]|\.\d{3}/g, "");
2052
2053
  const dateStamp = now.toISOString().slice(0, 10).replace(/-/g, "");
@@ -2065,7 +2066,7 @@ class S3Client2 {
2065
2066
  const signedHeaders = Object.keys(requestHeaders).sort().map((key) => key.toLowerCase()).join(";");
2066
2067
  const canonicalRequest = [
2067
2068
  "PUT",
2068
- `/${options.key}`,
2069
+ `/${encodedKey}`,
2069
2070
  "",
2070
2071
  canonicalHeaders,
2071
2072
  signedHeaders,
@@ -3009,6 +3010,7 @@ class S3Client2 {
3009
3010
  const dateStamp = now.toISOString().slice(0, 10).replace(/-/g, "");
3010
3011
  const credentialScope = `${dateStamp}/${this.region}/s3/aws4_request`;
3011
3012
  const credential = `${accessKeyId}/${credentialScope}`;
3013
+ const encodedKey = key.split("/").map((seg) => encodeURIComponent(seg)).join("/");
3012
3014
  const queryParams = new URLSearchParams({
3013
3015
  "X-Amz-Algorithm": "AWS4-HMAC-SHA256",
3014
3016
  "X-Amz-Credential": credential,
@@ -3018,7 +3020,7 @@ class S3Client2 {
3018
3020
  });
3019
3021
  const canonicalRequest = [
3020
3022
  "GET",
3021
- `/${key}`,
3023
+ `/${encodedKey}`,
3022
3024
  queryParams.toString(),
3023
3025
  `host:${host}
3024
3026
  `,
@@ -3039,7 +3041,7 @@ class S3Client2 {
3039
3041
  const kSigning = crypto3.createHmac("sha256", kService).update("aws4_request").digest();
3040
3042
  const signature = crypto3.createHmac("sha256", kSigning).update(stringToSign).digest("hex");
3041
3043
  queryParams.append("X-Amz-Signature", signature);
3042
- return `https://${host}/${key}?${queryParams.toString()}`;
3044
+ return `https://${host}/${encodedKey}?${queryParams.toString()}`;
3043
3045
  }
3044
3046
  generatePresignedPutUrl(bucket, key, contentType, expiresInSeconds = 3600) {
3045
3047
  const { accessKeyId, secretAccessKey } = this.getCredentials();
@@ -3049,6 +3051,7 @@ class S3Client2 {
3049
3051
  const dateStamp = now.toISOString().slice(0, 10).replace(/-/g, "");
3050
3052
  const credentialScope = `${dateStamp}/${this.region}/s3/aws4_request`;
3051
3053
  const credential = `${accessKeyId}/${credentialScope}`;
3054
+ const encodedKey = key.split("/").map((seg) => encodeURIComponent(seg)).join("/");
3052
3055
  const queryParams = new URLSearchParams({
3053
3056
  "X-Amz-Algorithm": "AWS4-HMAC-SHA256",
3054
3057
  "X-Amz-Credential": credential,
@@ -3058,7 +3061,7 @@ class S3Client2 {
3058
3061
  });
3059
3062
  const canonicalRequest = [
3060
3063
  "PUT",
3061
- `/${key}`,
3064
+ `/${encodedKey}`,
3062
3065
  queryParams.toString(),
3063
3066
  `content-type:${contentType}
3064
3067
  host:${host}
@@ -3080,7 +3083,7 @@ host:${host}
3080
3083
  const kSigning = crypto3.createHmac("sha256", kService).update("aws4_request").digest();
3081
3084
  const signature = crypto3.createHmac("sha256", kSigning).update(stringToSign).digest("hex");
3082
3085
  queryParams.append("X-Amz-Signature", signature);
3083
- return `https://${host}/${key}?${queryParams.toString()}`;
3086
+ return `https://${host}/${encodedKey}?${queryParams.toString()}`;
3084
3087
  }
3085
3088
  async createMultipartUpload(bucket, key, options) {
3086
3089
  const headers = {};
@@ -3275,7 +3278,7 @@ host:${host}
3275
3278
  }
3276
3279
  const sortedParams = Object.keys(queryParams).sort();
3277
3280
  const canonicalQuerystring = sortedParams.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(queryParams[k])}`).join("&");
3278
- const canonicalUri = "/" + key;
3281
+ const canonicalUri = "/" + key.split("/").map((seg) => encodeURIComponent(seg)).join("/");
3279
3282
  const canonicalHeaders = `host:${host}
3280
3283
  `;
3281
3284
  const signedHeaders = "host";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/ts-cloud",
3
3
  "type": "module",
4
- "version": "0.2.17",
4
+ "version": "0.2.18",
5
5
  "description": "A lightweight, performant infrastructure-as-code library and CLI for deploying both server-based (EC2) and serverless applications.",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
7
7
  "license": "MIT",
@@ -89,8 +89,8 @@
89
89
  "test": "bun test"
90
90
  },
91
91
  "dependencies": {
92
- "@ts-cloud/aws-types": "0.2.17",
93
- "@ts-cloud/core": "0.2.17",
92
+ "@ts-cloud/aws-types": "0.2.18",
93
+ "@ts-cloud/core": "0.2.18",
94
94
  "@stacksjs/ts-xml": "^0.1.0"
95
95
  },
96
96
  "devDependencies": {