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

"Signature is missing" when using quirrel with sveltekit in production mode #1128

Closed
bamthomas opened this issue Mar 24, 2023 · 4 comments · Fixed by #1131
Closed

"Signature is missing" when using quirrel with sveltekit in production mode #1128

bamthomas opened this issue Mar 24, 2023 · 4 comments · Fixed by #1131

Comments

@bamthomas
Copy link

bamthomas commented Mar 24, 2023

Bug Report

Current Behavior
When using quirrel with sveltekit in production we have the error Signature is missing when quirrel calls the app.

The code :

async respondTo(
    body: string,
    headers: IncomingHttpHeaders
  ): Promise<{
    status: number;
    headers: Record<string, string>;
    body: string;
  }> {
    if (process‧env.NODE_ENV === "production") {
      const signature = headers["x-quirrel-signature"];
      if (typeof signature !== "string") {
        return {
          status: 401,
          headers: {},
          body: "Signature missing",
        };
      }
    // ....
    }

Is getting undefined in the signature variable.

It seems that headers object is a Map and I'm not sure we can read the header with headers["x-quirrel-signature"] :

[Symbol(headers map)]: Map(9) {                                                                                                                                                                                  
    'content-type' => { name: 'content-type', value: 'text/plain' },                                                                                                                                                                                                                                                                                                                                      
    'x-quirrel-signature' => {                                                                                                                                                                                     
      name: 'x-quirrel-signature',                                                                                                                                                                                 
      value: '<signature>'                                                                                                                  
    },                                                                                                                                                                                                             
  // ....                                                                                                                                   
  },                                                                                                                                                                                                               
  [Symbol(headers map sorted)]: null                                                                                                                                                                               
}                                             

Expected behavior/code

The header is correctly read.

Environment

  • Quirrel version: [e‧g. v1.0.3] : latest docker version ghcr‧io/quirrel-dev/quirrel:sha-fbfa761
  • Node/npm version: [e‧g. Node 14/npm 6] : v18.12.1

Possible Solution

I'm not sure how to fix this (that's the reason I didn't make a PR) because :

headers‧get('x-quirrel-signature')

is working but maybe it won't work for other environments.

maybe :

const signature = typeof headers === 'Map' ? headers‧get('x-quirrel-signature') : headers['x-quirrel-signature]

What do you think ?
As a workaround I'm doing a sed in the file while building my app.

@Skn0tt
Copy link
Member

Skn0tt commented Apr 3, 2023

Thanks for the detailed report! Looks like SvelteKit changed the types of the request object. I'm working on a fix in #1131, will ping here when it's released.

@all-contributors please add @bamthomas for bug

@allcontributors
Copy link
Contributor

@Skn0tt

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

I've put up a pull request to add @bamthomas! 🎉

Skn0tt pushed a commit that referenced this issue Apr 3, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Adds @bamthomas as a contributor for bug.

This was requested by Skn0tt [in this
comment](#1128 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Skn0tt added a commit that referenced this issue Apr 3, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Closes #1128
@Skn0tt
Copy link
Member

Skn0tt commented Apr 3, 2023

Shipped in https://github.com/quirrel-dev/quirrel/releases/tag/v1.13.3, please let me know if that works for you.

@bamthomas
Copy link
Author

Thank you very much for the fix and the add.

I'm going to test it soon, I will update this comment.

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

Successfully merging a pull request may close this issue.

2 participants