-
Notifications
You must be signed in to change notification settings - Fork 396
feat(clerk-js,types): Add web3_coinbase_signature strategy on sign in/up flows #3940
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
Conversation
|
!snapshot |
53606b8
to
aadf3ba
Compare
Hey @EmmanouelaPothitou - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@1.0.11-snapshot.vaadf3ba --save-exact
npm i @clerk/backend@1.6.2-snapshot.vaadf3ba --save-exact
npm i @clerk/chrome-extension@1.1.13-snapshot.vaadf3ba --save-exact
npm i @clerk/clerk-js@5.14.0-snapshot.vaadf3ba --save-exact
npm i @clerk/elements@0.12.4-snapshot.vaadf3ba --save-exact
npm i @clerk/clerk-expo@2.1.0-snapshot.vaadf3ba --save-exact
npm i @clerk/express@0.0.27-snapshot.vaadf3ba --save-exact
npm i @clerk/fastify@1.0.29-snapshot.vaadf3ba --save-exact
npm i @clerk/localizations@2.5.7-snapshot.vaadf3ba --save-exact
npm i @clerk/nextjs@5.3.0-snapshot.vaadf3ba --save-exact
npm i @clerk/clerk-react@5.4.0-snapshot.vaadf3ba --save-exact
npm i @clerk/remix@4.2.13-snapshot.vaadf3ba --save-exact
npm i @clerk/clerk-sdk-node@5.0.26-snapshot.vaadf3ba --save-exact
npm i @clerk/shared@2.5.0-snapshot.vaadf3ba --save-exact
npm i @clerk/tanstack-start@0.2.0-snapshot.vaadf3ba --save-exact
npm i @clerk/testing@1.2.9-snapshot.vaadf3ba --save-exact
npm i @clerk/themes@2.1.19-snapshot.vaadf3ba --save-exact
npm i @clerk/types@4.13.0-snapshot.vaadf3ba --save-exact |
@EmmanouelaPothitou 👋🏻 |
ee19cb8
to
70afda5
Compare
} | ||
}; | ||
|
||
public authenticateWithWeb3 = async ({ |
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.
❓ As we are introducing a new generic authenticateWithWeb3()
function, we should also use it on the existing authenticateWithMetamask()
method in order to DRY to code and avoid duplicating the logic
Also are we looking to introduce the corresponding authenticateWithCoinbase()
method?
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.
I think we have 2 options here:
- Deprecate authenticateWithMetamask and recommend transitioning to authenticateWithWeb3.
- Retain authenticateWithMetamask, introduce authenticateWithCoinbase and optionally mark authenticateWithWeb3 as private.
|
||
prepareWeb3WalletVerification = (): Promise<SignUpResource> => { | ||
return this.prepareVerification({ strategy: 'web3_metamask_signature' }); | ||
prepareWeb3WalletVerification = (strategy: Web3Strategy): Promise<SignUpResource> => { |
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.
⛔ Isn't this a breaking change?
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.
unfortunately yes, strategy
needs to be optional and fallback to 'web3_metamask_signature'
packages/types/src/signUp.ts
Outdated
attemptPhoneNumberVerification: (params: AttemptPhoneNumberVerificationParams) => Promise<SignUpResource>; | ||
|
||
prepareWeb3WalletVerification: () => Promise<SignUpResource>; | ||
prepareWeb3WalletVerification: (strategy: Web3Strategy) => Promise<SignUpResource>; |
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.
⛔ Isn't this a breaking change?
packages/types/src/web3Wallet.ts
Outdated
|
||
export type AttemptWeb3WalletVerificationParams = { | ||
signature: string; | ||
strategy: Web3Strategy; |
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.
⛔ Same here about a breaking change
packages/types/src/web3Wallet.ts
Outdated
export interface AuthenticateWithWeb3Params { | ||
identifier: string; | ||
generateSignature: GenerateSignature; | ||
provider: 'metamask' | 'coinbase'; |
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.
⛔ Breaking change here as well
function getMetamaskProvider(): any { | ||
// @ts-ignore | ||
if (!global.ethereum) { | ||
return undefined; | ||
} | ||
|
||
// @ts-ignore | ||
if (global.ethereum.providers) { | ||
// @ts-ignore | ||
return global.ethereum.providers[1]; | ||
} | ||
|
||
// @ts-ignore | ||
if (!global.ethereum.isMetaMask) { | ||
return undefined; | ||
} | ||
|
||
// @ts-ignore | ||
return global.ethereum; | ||
} | ||
|
||
function getCoinbaseProvider(): any { | ||
// @ts-ignore | ||
if (!global.ethereum) { | ||
return undefined; | ||
} | ||
|
||
// @ts-ignore | ||
if (global.ethereum.providers) { | ||
// @ts-ignore | ||
return global.ethereum.providers[0]; | ||
} | ||
|
||
// @ts-ignore | ||
if (!global.ethereum.isCoinbaseWallet) { | ||
return undefined; | ||
} | ||
|
||
// @ts-ignore | ||
return global.ethereum; | ||
} |
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.
🔧 We should find a more fine-grained way to use the ethereum provider in case there are multiple injected (e.g. user has MetaMask and Coinbase Wallet extensions).
We also have a separate ticket to deal with this edge case
441e0db
to
3b521d6
Compare
3b521d6
to
ff6068b
Compare
Description
Support a new strategy
web3_coinbase_signature
during sign in/up flows that uses the Coinbase Wallet.Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change