Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: headers[headerName].trim is not a function #1334

Open
chhornponleu opened this issue Jul 12, 2024 · 0 comments
Open

TypeError: headers[headerName].trim is not a function #1334

chhornponleu opened this issue Jul 12, 2024 · 0 comments

Comments

@chhornponleu
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @smithy/signature-v4@2.1.3 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@smithy/signature-v4/dist-cjs/index.js b/node_modules/@smithy/signature-v4/dist-cjs/index.js
index fd7e634..66d27b8 100644
--- a/node_modules/@smithy/signature-v4/dist-cjs/index.js
+++ b/node_modules/@smithy/signature-v4/dist-cjs/index.js
@@ -126,7 +126,12 @@ var getCanonicalHeaders = /* @__PURE__ */ __name(({ headers }, unsignableHeaders
         continue;
       }
     }
-    canonical[canonicalHeaderName] = headers[headerName].trim().replace(/\s+/g, " ");
+    if (typeof headers?.[headerName] === 'string') {
+      canonical[canonicalHeaderName] = headers[headerName].trim().replace(/\s+/g, " ");
+    }
+    else {
+      canonical[canonicalHeaderName] = headers[headerName]
+    }
   }
   return canonical;
 }, "getCanonicalHeaders");
@@ -435,8 +440,8 @@ ${(0, import_util_hex_encoding.toHex)(hashedRequest)}`;
   }
   validateResolvedCredentials(credentials) {
     if (typeof credentials !== "object" || // @ts-expect-error: Property 'accessKeyId' does not exist on type 'object'.ts(2339)
-    typeof credentials.accessKeyId !== "string" || // @ts-expect-error: Property 'secretAccessKey' does not exist on type 'object'.ts(2339)
-    typeof credentials.secretAccessKey !== "string") {
+      typeof credentials.accessKeyId !== "string" || // @ts-expect-error: Property 'secretAccessKey' does not exist on type 'object'.ts(2339)
+      typeof credentials.secretAccessKey !== "string") {
       throw new Error("Resolved credential object is not valid");
     }
   }

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant