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

Expose auth providers from taco #534

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

piotr-roslaniec
Copy link
Contributor

@piotr-roslaniec piotr-roslaniec commented Jun 25, 2024

Type of PR:

  • Feature

Required reviews:

  • 2

What this does:

  • decrypt method in taco now takes authProvider: EIP4361 instead of signer: ethers.Signer
  • Exposes EIP4361Provider from taco rather than taco-auth to avoid fragmenting TACo API across multiple packages. To be reassessed when/if we publish taco-auth
  • Users can now modify SIWE parameters in EIP4361Provider

Issues fixed/closed:

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network.
E.g., if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

  • Fails on Lynx because of incompatibility with v7.3.0

@piotr-roslaniec piotr-roslaniec changed the base branch from main to epic-auth June 25, 2024 09:11
Copy link

netlify bot commented Jun 25, 2024

Deploy Preview for taco-nft-demo ready!

Name Link
🔨 Latest commit 80b680d
🔍 Latest deploy log https://app.netlify.com/sites/taco-nft-demo/deploys/667a89a072bbf50008f88bc2
😎 Deploy Preview https://deploy-preview-534--taco-nft-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jun 25, 2024

Deploy Preview for taco-demo ready!

Name Link
🔨 Latest commit 80b680d
🔍 Latest deploy log https://app.netlify.com/sites/taco-demo/deploys/667a89a079ae120008dd40e9
😎 Deploy Preview https://deploy-preview-534--taco-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@piotr-roslaniec piotr-roslaniec force-pushed the expose-auth-providers branch 4 times, most recently from 934d7e6 to cba9fbd Compare June 26, 2024 12:56
@piotr-roslaniec piotr-roslaniec mentioned this pull request Jul 1, 2024
17 tasks
@piotr-roslaniec piotr-roslaniec force-pushed the expose-auth-providers branch from cba9fbd to 51e5402 Compare July 1, 2024 10:44
@piotr-roslaniec piotr-roslaniec force-pushed the expose-auth-providers branch 3 times, most recently from 9ac0d00 to 582d140 Compare July 3, 2024 12:29
@piotr-roslaniec piotr-roslaniec marked this pull request as ready for review July 4, 2024 10:46
Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

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

LGTM! 🙌

I just left a little thought I had.

packages/taco-auth/src/providers/eip4361.ts Show resolved Hide resolved
Comment on lines 40 to 44
const maybeOrigin = window?.location?.origin;
return {
domain: maybeOrigin.split('//')[1].split('.')[0],
uri: maybeOrigin,
};
Copy link
Member

Choose a reason for hiding this comment

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

Judging by this code here - https://1.x.wagmi.sh/examples/sign-in-with-ethereum#step-3-sign--verify-message, assuming window.location is available, can we just use the host property for the domain value instead of the parsing?

Also, out of curiosity is document an option in addition to window? Noticed this here - https://github.com/spruceid/siwe-notepad/blob/main/src/providers.ts#L132. Not sure what environment document is available ... 🤔

Copy link
Contributor Author

@piotr-roslaniec piotr-roslaniec Jul 9, 2024

Choose a reason for hiding this comment

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

Yes, document and window are globally available objects provided by the browser environment.

I updated this snippet.

provider: ethers.providers.Provider,
domain: Domain,
messageKit: ThresholdMessageKit,
authProviders?: AuthProviders,
Copy link
Member

Choose a reason for hiding this comment

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

Interested to see what this parameter looks like when EIP712 eventually gets removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't foresee new providers near-term, it could be just authProvider: EIP4361Provider

packages/taco/src/taco.ts Outdated Show resolved Hide resolved
@piotr-roslaniec piotr-roslaniec force-pushed the expose-auth-providers branch 4 times, most recently from 05a2248 to 4687bc6 Compare July 9, 2024 14:22
@piotr-roslaniec piotr-roslaniec added the blocked The progress on this issue is blocked for some reason label Jul 9, 2024
@@ -46,7 +64,7 @@ export class EIP4361AuthProvider {

private async createSIWEAuthMessage(): Promise<AuthSignature> {
const address = await this.signer.getAddress();
const { domain, uri } = this.getParametersOrDefault();
const { domain, uri } = this.providerParams;
const version = '1';
const nonce = generateNonce();
const chainId = (await this.provider.getNetwork()).chainId;
Copy link
Member

@derekpierre derekpierre Jul 9, 2024

Choose a reason for hiding this comment

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

Can we do signer.getChainId( ) here? Then we can get rid of provider from the constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not every signer has a connected provider. In ethers, it's possible to create a signer using a raw private key without ever connecting to an RPC.

I think we may want to explore requiring that every signer has a provider already connected and to do that in the whole codebase. But I think this is for another PR since we would be changing quite a lot of APIs.

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok.

packages/taco/src/taco.ts Outdated Show resolved Hide resolved
Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

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

LGTM! 👌

Copy link
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

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

🎸

@derekpierre derekpierre merged commit 28b3592 into nucypher:epic-auth Jul 10, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked The progress on this issue is blocked for some reason
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose authentication providers from @nucypher/taco
3 participants