Sign in with Solana type error and subsequent failure when types are fixed. #94
-
SummaryHey Phantom team! I recently started going through your Sign-in with Solana example and implemented a PoC in our app. I copied the code examples over to our project with both our variables for the sign-in message, as well as an empty sign-in example. On each of them, I would get a Type error after I sent the stringified object to our backend. After the type error was addressed it just proceeded to fail verification. Examplehttps://splits-git-dev-solsplits.vercel.app/ Steps to ReproduceHey Phantom team! I recently started going through your Sign-in with Solana example and implemented a PoC in our app. I copied the code examples over to our project with both our variables for the sign-in message, as well as an empty sign-in example. On each of them, I would get an error after I sent the stringified object to our backend. This is our AutoSignIn function:
}, []);` I would destructure the object like the example provided this is my backend route. `import { withIronSessionApiRoute } from "iron-session/next"; const supabase = supabaseServiceLevel switch (method) {
}
If I ended up changing the signature and signedMessage to Uint8Arrays like so...
In this example it would stop giving me the type errors, but every single time the verification would fail. Has anyone else had issues like this? Phantom VersionNo response Is there an existing discussion for this?
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Getting the same error but for me it's for the input argument of the verifySignInFunction:
Basically doing the exact same thing:
If I log the input that I pass into this function I see this:
Help would be appreciated |
Beta Was this translation helpful? Give feedback.
-
@afisherdev @KultureElectric Can you please log both the input and the output on the backend, just before If you can share these inputs and outputs with me, that would be nice |
Beta Was this translation helpful? Give feedback.
-
Input:
Output:
Based on that I would assume it should work. The Input types are all strings and in the output object I serialized everything into Uint8Arrays. Error remains the same: |
Beta Was this translation helpful? Give feedback.
-
Actually Anvit was already able to help me solve it: The Output object has to be formatted with Array.from() on the client side So on the client I need to do this: let strPayload = JSON.stringify({ input, output: { const verifyResponse = await fetch("/api/wallet/verifySIWS", { And then on my server I do as you say and reformat it back to a Uint8Array: const deconstructPayload: { const backendInput = deconstructPayload.input; const verificationResult = verifySignIn(backendInput, backendOutput); Based on that I don't think the demonstration example would work for others. Probably best if you changed it. Thanks a lot for your help! 🙏 |
Beta Was this translation helpful? Give feedback.
Actually Anvit was already able to help me solve it:
The Output object has to be formatted with Array.from() on the client side
-> Because apparently Uint8Arrays can't be Json.stringified
So on the client I need to do this:
let strPayload = JSON.stringify({ input, output: {
account: {
address: output.account.address,
publicKey: Array.from(output.account.publicKey),
},
signature: Array.from(output["signature"]),
signedMessage: Array.from(output["signedMessage"]),
} });
const verifyResponse = await fetch("/api/wallet/verifySIWS", {
method: "POST",
body: strPayload,
});
And then on my server I do as you say and reformat it back to a Uint8Array:
const deconstructPayload: {
input: SolanaSignIn…