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

Copilot siwe #204

Merged
merged 68 commits into from
Jan 7, 2025
Merged

Conversation

MateuszStawski
Copy link
Contributor

No description provided.

MateuszStawski and others added 30 commits November 24, 2024 15:46
MateuszStawski and others added 21 commits December 21, 2024 02:10
Co-authored-by: Daniel Chutkowski <[email protected]>
Co-authored-by: SolutionsEngineer <[email protected]>
Co-authored-by: 21142 <[email protected]>
Copy link
Collaborator

@daniel0ar daniel0ar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctly implements dynamically forming the SIWE message by receiving a domain parameter in the API. Changed the type in the extension side and sent it in the hook handle function.

@lennardevertz
Copy link
Member

lennardevertz commented Jan 4, 2025

please siwtch targeted branch to copilot-dev @MateuszStawski

@lennardevertz
Copy link
Member

lennardevertz commented Jan 4, 2025

Correctly implements dynamically forming the SIWE message by receiving a domain parameter in the API. Changed the type in the extension side and sent it in the hook handle function.

Is this correctly implemented from the backend api side already? is verification successful? @daniel0ar

@MateuszStawski MateuszStawski changed the base branch from master to copilot-dev January 6, 2025 18:38
@daniel0ar
Copy link
Collaborator

As it is right now, the API won't respond with a jwt token unless verification is succesful. In my tests, all signed messages sent by the user are being verified succesfully with the provided publicClient on the API /login endpoint.

The only thing I would add for security is the nonce verification too, like this (line 29 of copilot-api/routes/auth.ts):

const valid = await publicClient.verifySiweMessage({
      address: walletAddress,
      message,
      signature,
      nonce,
    });

and line 21 of the same file:

const { signature, walletAddress, message, nonce } = req.body;

This means that the user on the extension side should also send the nonce they received from /wallet-address API endpoint.

This can be a separate PR or it can be included here.

@lennardevertz
Copy link
Member

As it is right now, the API won't respond with a jwt token unless verification is succesful. In my tests, all signed messages sent by the user are being verified succesfully with the provided publicClient on the API /login endpoint.

The only thing I would add for security is the nonce verification too, like this (line 29 of copilot-api/routes/auth.ts):

const valid = await publicClient.verifySiweMessage({
      address: walletAddress,
      message,
      signature,
      nonce,
    });

and line 21 of the same file:

const { signature, walletAddress, message, nonce } = req.body;

This means that the user on the extension side should also send the nonce they received from /wallet-address API endpoint.

This can be a separate PR or it can be included here.

lets do separate

@lennardevertz lennardevertz merged commit db17a44 into idriss-xyz:copilot-dev Jan 7, 2025
5 checks passed
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 this pull request may close these issues.

5 participants