-
Notifications
You must be signed in to change notification settings - Fork 22
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
Expose auth providers from taco
#534
Conversation
✅ Deploy Preview for taco-nft-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for taco-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
934d7e6
to
cba9fbd
Compare
cba9fbd
to
51e5402
Compare
4eea8e7
to
5a4d072
Compare
9ac0d00
to
582d140
Compare
582d140
to
9ce1a99
Compare
There was a problem hiding this 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.
const maybeOrigin = window?.location?.origin; | ||
return { | ||
domain: maybeOrigin.split('//')[1].split('.')[0], | ||
uri: maybeOrigin, | ||
}; |
There was a problem hiding this comment.
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 ... 🤔
There was a problem hiding this comment.
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.
packages/taco/src/taco.ts
Outdated
provider: ethers.providers.Provider, | ||
domain: Domain, | ||
messageKit: ThresholdMessageKit, | ||
authProviders?: AuthProviders, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
05a2248
to
4687bc6
Compare
4687bc6
to
f452c6a
Compare
@@ -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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎸
Type of PR:
Required reviews:
What this does:
decrypt
method intaco
now takesauthProvider: EIP4361
instead ofsigner: ethers.Signer
EIP4361Provider
fromtaco
rather thantaco-auth
to avoid fragmenting TACo API across multiple packages. To be reassessed when/if we publishtaco-auth
EIP4361Provider
Issues fixed/closed:
@nucypher/taco
#533Why it's needed:
Notes for reviewers: