-
Notifications
You must be signed in to change notification settings - Fork 85
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
feat: Add farcaster extension #750
Conversation
|
||
callback(data as any); | ||
|
||
if (!showUI) return; |
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 showUI is false, will login the happen?
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, under this if statement is just for show QRCode in mandrake,
if showUI is false, we don't show our QRCode popup, developer should display their QRCode design.
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.
A follow-up question, How would the developer know it's time to show the QRCode?
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.
QRCode shows when dev calls magic.farcaster.login({ showUI: true })
So dev can add this function on Sign in with Farcaster
Button onClick
const handle = { | ||
on: <T extends EventName>(event: T, callback: (params: EventMap[T]) => void) => { | ||
if (event === EVENT.CHANNEL) { | ||
!(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.
Why do we need an exclamation mark here?
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.
@@ -146,6 +146,10 @@ export enum AuthEventOnReceived { | |||
IDTokenCreated = 'Auth/id-token-created', | |||
} | |||
|
|||
export enum FarcasterLoginEventEmit { | |||
SuccessSignIn = 'success_sign_in', |
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.
Could we turn this to farcaster/success_sign_in
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.
Is there a reason this logic can't be in the iframe? I think it's more maintainable that way where the sdk just sends an rpc method |
callback(data as any); | ||
channel_token = data.channelToken; | ||
|
||
if (isMobile()) { |
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 noticed a potential issue when the user is on a mobile device. The showUI
condition won't have any effect in that case. If that's by design, I'd suggest putting a console warning or info to explain this. Otherwise, people might ask why the flag is not working.
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.
yeah it's by design, we don't display QR on mobile device, and just open channel URL.
I will add console info
@@ -9,7 +9,7 @@ async function main() { | |||
const PKG = await promptForPackage(); | |||
|
|||
printSeparator('Linting TypeScripts'); | |||
await execa('yarn', ['wsrun', '--serial', 'eslint', '--fix', '.'], { | |||
await execa('yarn', ['wsrun', '--serial', 'eslint', '--fix'], { |
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.
Does this skip the linter stage?
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 changed this to fix below typescript-eslint issue (explained below)
@@ -69,7 +70,7 @@ | |||
"ts-node": "^10.2.0", | |||
"tsc-watch": "^4.2.9", | |||
"tslib": "^2.3.1", | |||
"typescript": "~4.4.2", | |||
"typescript": "^5.4.5", |
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'd suggest not to bump the typescript version, as it might break other implementations. We'll need a thorough code scan once we bump the version
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 bumped because @farcaster/auth-client
library dependent to viem
and viem has peerDependency to TypeScript >5.0.4 https://github.com/wevm/viem/blob/main/src/package.json#L117
So it breaks CI when I installed viem in @magic-ext/farcaster
When I initially designed the implementation, I thought that in the case where the user set And to get both socket channel open event and success event from handler to farcaster login relayer, I thought it was similar because I need to send events from mandrake side to iframe side anyway. |
I think it'd be a lot simpler to maintain to have the logic in mandrake, and future updates would not require new sdk versions, but if there's a good reason why it needs to be in magic-js I'm open to doing it in here |
I believe the reason is that Farcaster, as a type of social login, may block authentication requests submitted from iframes or webviews in the future as a security measure, similar to Google OAuth. |
channel_token = data.channelToken; | ||
|
||
if (isMobile()) { | ||
console.info(`Info: showUI parameter is ignored on mobile, open URL directly`); |
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.
This console.info should be 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.
I added this from @Ethella 's review: #750 (comment)
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.
Could you change the message to Magic -> farcaster extension: showUI parameter is ignored on mobile, open URL directly
@ysm-dev The deepsource errors are from the uses of |
Created @magic-ext/farcaster package for CI publishing |
Please address the deepsource, otherwise LGTM |
π PR was released in |
π¦ Pull Request
[Provide a general summary of the pull request here.]
β Fixed Issues
π¨ Test instructions
[Describe any additional context required to test the PR/feature/bug fix.]
Please π¨ ONLY ADD ONE π¨ of the following labels, failing to do so may lead to adverse versioning of your changes when published:
patch
: Bug Fix?minor
: New Feature?major
: Breaking Change?skip-release
: It's unnecessary to publish this change.Special Note
Please avoid adding any of the
Priority
labels as they conflict with the labels above βοΈπ¦ Published PR as canary version:
Canary Versions
β¨ Test out this PR locally via: