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

[Connect] Error during auth request Error: Improperly formatted private-key. Private-key byte length should be 32 or 33. Length provided: 390 #321

Open
himmelhargott opened this issue Apr 29, 2023 · 13 comments
Assignees
Labels

Comments

@himmelhargott
Copy link

Hello,

I hope this is a wallet issue, otherwise feel free to relocate, since I am somewhat at a loss.

I try to find out, why this message is happening:
While developping a webapp locally, everthing went fine (as with parcel as with snowpack, tried both).

To connect to the app i use showConnect from @stacks/connect
This opens the wallet extension, which I can unlock with the password.
Then I can choose an account. When clicking on one, this error is in the browser console:

AuthRequestError

As long as i serve the project with parcel or snowpack on localhost, everything works fine.
As soon as I build the project with either one of them the error occurs. If I omit the login, the rest oft the project works (except all that is linked to userData of course)

the import is done like so through the snowpack builder:
import { showConnect } from "./_snowpack/pkg/@stacks/connect.js";
the webserver is nginx on a raspberryPi 4.
The project has NO domain ONLY the internal IP of the raspPi (like 192.168.0.1) -> maybe thats the problem? If so, is there an easy way around that problem?

Hope very much that anyone can help me or show me a workaround, since I spent almost 2 month with learning and programming that app.

Many thanks in advance!
Best Regards
Stefan

@markmhendrickson
Copy link
Contributor

@kyranjamie any initial ideas here?

@kyranjamie
Copy link
Contributor

This is more an issue with connect, nothing is running in the wallet's context here.

Would be helpful to debug and see what the key is that's 390 length (but ofc that shouldn't be shared). Wonder if this is some snowpack bundling issue.

Transferring to Connect repo.

@kyranjamie kyranjamie transferred this issue from leather-wallet/extension May 1, 2023
@himmelhargott
Copy link
Author

Here is the repo:

with it it should be possible for you to recreate the error:

https://github.com/himmelhargott/prt.git

with npm start, serving locally with snowpack, there is no problem chosing an account in the wallet an logging in.

yet served on the raspPi4 with nginx (bundled with parcel or snowpack, tried both, both with the same error) I can choose an account and then get the above error.

I am somewhat desperate. Would appreciate very much if someone could look into it.

And thanks for the work done so far.

Best regards
Stefan

@janniks
Copy link
Collaborator

janniks commented May 4, 2023

This seems to be a build issue, likely unrelated to Stacks connect. Closing issue as unrelated...

Are you serving the build directory via nginx? It works with npm run build and then npx serve build -- so the build step works, I believe. Likely a hosting related issue (maybe with the nginx config)

@janniks janniks closed this as completed May 4, 2023
@himmelhargott
Copy link
Author

Thank you very much for looking into it!

@himmelhargott
Copy link
Author

follow up question:

since I am still stuck with the problem:

I did the same:
cloned the repo from github, then
npm run build and then npx serve build
seems to work:
npxServe

now with serving: I can choose local or network via link (see screenshot above)
with local the programm works fine
with network the same error occurs as mentioned above (now i am on the same machine, same bundler, same served files only once I connect over the locally served files, everything works, when i connect (without interruption or changing anything) via network the error ensues and i get back a key that is 390 characters long. Since I am not creating that key ( it s the response of a query to stacks, if I understand this correctly) I am not so sure if there isnt a bug on the serverside (stacks). I think what changes on my side is only the domain? - local http://localhost:3000/, network: http://192.168.178.23:3000/ could it be there is a problem with that? since the domain is used to generate the key?

did you try the same? did it work via network?

thanks for a quick update.

@janniks
Copy link
Collaborator

janniks commented May 5, 2023

Can you try this link? https://n4yi3m-3000.csb.app/

@himmelhargott
Copy link
Author

himmelhargott commented May 5, 2023 via email

@janniks
Copy link
Collaborator

janniks commented May 5, 2023

Hard to say, likely some weird install/version/build issue; might be something on the browser / extensions.

This codesandbox is forked from your reproduction repo: https://codesandbox.io/p/sandbox/competent-hellman-n4yi3m you might be able to work in a similar environment. Not sure how to best deploy to raspi

@himmelhargott
Copy link
Author

Thank you very much!

For now I will try it like this.
Since it is only for MVP its no big deal. And I dont think the final version is on a raspi.

Yet on a Windows machine, I had the same problem.
Hopefully I will finally run it on a linux machine or vm and all will be fine =)

@himmelhargott
Copy link
Author

As it looks to me the "problem" lies in not having a domain in document.location.href since as I understand it correctly this is used to generate the key. So in case of there is a IP address instead of a domain, there ensues the error (out of reasons unbeknownst to me)

As soon as the some code is served with a domain, everything works fine.
Yet it s not so much of a bug since only the minority will want to test their app without a domain.

My solution up to now is to use tiiny.host to test the project. As such it is online as a normal website and this 24/7 for possible customers to test and play around.

Thank you very much for your cooperation.

Best regards
S

@janniks
Copy link
Collaborator

janniks commented May 6, 2023

Cool, thanks for the investigation! I’ll re-open so we fix this at some point 🙏🏻

@janniks janniks reopened this May 6, 2023
@himmelhargott
Copy link
Author

=) pleasure

though I would like to point out, that its only my best guess and a possible vector to investigate in.
Not sure if its the real problem.

happy coding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 📋 Backlog
Development

No branches or pull requests

4 participants